2

Well i've been looking how to do an auto updater on google, however no success.

What i would plan is to create an updater (ANother exe called by QProcess though the principal exe) but here ihave some questions:

How do i make the QProcess silent? If there's a new version, how do i show a notification on the window from where the process has been started (I meant i've create the process in Game.exe, i want to send a notification to Game.exe from Updater.exe that there's a new version available.)

Thanks for the answers.

Kazuma
  • 1,371
  • 6
  • 19
  • 33

1 Answers1

0

First, I've never encountered a need to create anything other than a QThread to handle my update needs. The QProcess would be helpful if, once the user updates, you want to download, install, and relaunch the program while the user continues with the main program. (But this can all be achieved with a shell script, python script, even BAT file)

When you use QProcess, you will have to rely on the signals readyReadStandardError() and readyReadStandardOutput(). Then the application that your process is calling should send its output to stderr or stdout. Updater.exe should write to either of these files.

I would imagine your Updater to make use of QNetworkAccessManager::finished(QNetworkReply *reply). When this slot is called, please do something nicer than this:

void Updater::replyFinished(QNetworkReply *reply){
    QString r(reply->readAll());
    if(r.contains(SERVER_REPLY_UPDATE_AVAILABLE)){
        qDebug() << "yes";
    }else{
        qDebug() << "no";
        QApplication::quit();
    }
}  

If Updater.exe is going to be a full blown GUI application, do not call the show() method unless it's needed and it should appear to run in the background. I would prefer a script, but you know me.

Then your Game.exe will set up a QProcess. You can pass arguments to the process within the QProcess::start() function.

Good arguments that will help direct your update process would be:

  • Game.exe version number
  • "check_for_updates"
  • "ignore_updates"
  • "download_update"

finally, in Game.exe:

...
connect(process,SIGNAL(readyReadStandardError()),this,SLOT(readProcessReply()));
...

void Game::readProcessReply(){
    QString r(process->readAllStandardError());
    if(r.contains("yes")){
        //show your dialog here
    }else{
        //do nothing
    }
}
buster
  • 1,038
  • 7
  • 16