Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Download and Update a Qt Program on Linux
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Download and Update a Qt Program on Linux

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CKurduC Offline
    CKurduC Offline
    CKurdu
    wrote on last edited by CKurdu
    #1

    Hi everybody

    I am trying the programming an update system for my qt program.

    void MainWindow::updateDownloaded()
    {
        #ifdef Q_WS_WIN
            QString fileName = QString("Updater-%1.exe").arg(VERSION);
        #endif
        #ifdef Q_OS_LINUX
            QString fileName = QString("Updater-%1.run").arg(VERSION);
        #endif;
        qDebug()<<"One update has been downloaded."<<endl;
        QFile file(fileName);
        if(file.open(QIODevice::WriteOnly))
        {
            file.write(this->downloader->downloadedData());
            #ifdef Q_OS_LINUX
                file.setPermissions(QFile::ExeOther|QFile::ExeOwner|QFile::ExeGroup|QFile::ReadUser|QFile::ReadOther|QFile::ReadGroup|QFile::ReadOwner|QFile::WriteUser);
            #endif;
            QProcess *process = new QProcess(this);
            qDebug() << QDir::currentPath()+QDir::separator()+fileName<<endl;
            connect(process,SIGNAL(error(QProcess::ProcessError)),this,SLOT(processErrorOccured(QProcess::ProcessError)));
            process->start(QDir::currentPath()+QDir::separator()+fileName);
    
        }
        delete this->downloader;
    
    }
    
    void MainWindow::processErrorOccured(QProcess::ProcessError err)
    {
        switch(err)
        {
        case QProcess::FailedToStart:
            qDebug()<<"Failed to start"<<endl;
            break;
        case QProcess::Crashed:
            qDebug()<<"Creached"<<endl;
            break;
        case QProcess::Timedout:
            qDebug()<<"Timedout"<<endl;
            break;
        case QProcess::WriteError:
            qDebug()<<"WriteError"<<endl;
            break;
        case QProcess::ReadError:
            qDebug()<<"ReadError"<<endl;
            break;
        case QProcess::UnknownError:
            qDebug()<<"UnknowError"<<endl;
            break;
        }
    
    }
    
    

    But I get "failed to start" error. When I try to run downloaded updater by clicking, program starts as expected. Program has right permissions to execute.

    You reap what you sow it

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      Maybe close the file after you write to it and before you try to start the QProcess.

      1 Reply Last reply
      0
      • CKurduC Offline
        CKurduC Offline
        CKurdu
        wrote on last edited by
        #3

        Thank you mchinand. It works now.

        You reap what you sow it

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #4

          Great! Just curious, how do you create the updater executables? Are they binary diffs between the versions?

          1 Reply Last reply
          0
          • CKurduC Offline
            CKurduC Offline
            CKurdu
            wrote on last edited by
            #5

            Actually dll files and modules that changed or removed and update script. I will combine all of them in a single executable.

            You reap what you sow it

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved