Qt Installer Framework: Auto Update

后端 未结 3 772
一生所求
一生所求 2021-01-31 11:59

I\'m currently using the Qt Installer Framework and managed to set up an online repository. What I want to know is:

Does the Framework provide some kind of \"auto-update

3条回答
  •  不知归路
    2021-01-31 12:21

    What I do, is run the maintenance tool using QProcess, and then check the output. It has a mode where it doesn't run the GUI but only outputs update information if available.

    Note that I set the working directory to the application's path when the applications starts, so I can just run maintenancetool.

    QProcess process;
    process.start("maintenancetool --checkupdates");
    
    // Wait until the update tool is finished
    process.waitForFinished();
    
    if(process.error() != QProcess::UnknownError)
    {
        qDebug() << "Error checking for updates";
        return false;
    }
    
    // Read the output
    QByteArray data = process.readAllStandardOutput();
    
    // No output means no updates available
    // Note that the exit code will also be 1, but we don't use that
    // Also note that we should parse the output instead of just checking if it is empty if we want specific update info
    if(data.isEmpty())
    {
        qDebug() << "No updates available";
        return false;
    }
    
    // Call the maintenance tool binary
    // Note: we start it detached because this application need to close for the update
    QStringList args("--updater");
    bool success = QProcess::startDetached("maintenancetool", args);
    
    // Close the application
    qApp->closeAllWindows();
    

提交回复
热议问题