Maintenancetool and QProcess, --checkupdates argument



  • Hi everyone,

    I'm using the QtInstallerframework to distribut my program and keep it up to date. I'm quite happy with it, and it works well enough for my case.

    I would now like to streamline the update, add and remove packages process for the user. I thought about downloading and parsing the xml files myself and downloading and decompressing the 7z files too, but I realised that the maintenancetool has nearly all features build in, and I could simply use QProcess and an argument string list.

    But, I'm a bit confused about how it's working, take for example this code

        QStringList args;args << "--checkupdates";
        qDebug() << "####" << endl;
        int exitCode = QProcess::execute("C:/path//to/the/maintenancetool.exe", args);
        qDebug() << endl << "exitCode" << exitCode;
    

    it returns, 1 when no updates are available, and 0 when there are some, easy enough.

    However looking at the Applicationoutput console, I see this:
    0_1530855237974_1b6aef9b-6024-4aa2-a948-8ebbf55b33a5-image.png

    Where does the xml formated part come from !? oO And is there a way to catch that string for further evaluations? It would save me from parsing the generated components.xml file

    Greetings.


  • Moderators

    Perhaps you need to merge the output channels. See the docs



  • @sierdzio ah, I see!

    So far my experience with QProcess is limited, so thanks for the given direction!

    I was able to adjust the "process" with QProcess 😏

    For what ever reason, I was forced to create the QProcess object on the heap and use start instead of execute.
    Or the process would still send the output to the standartoutput.

        QStringList args;args << "--checkupdates";
        qDebug() << "####" << endl;
        QProcess *process = new QProcess(this);
    
        qDebug() << process->processChannelMode();
        process->setProcessChannelMode(QProcess::MergedChannels);
        qDebug() << process->processChannelMode();
    
        process->start("C:/Path/To/the/maintenancetool.exe", args);
    
        connect(process, QOverload<int>::of(&QProcess::finished), this, [=](int exitCode){
            qDebug() << endl << "exitCode" << exitCode;
            qDebug() << process->readAll() << endl;
        });
    

    0_1530858422878_a7f04752-528c-4687-9407-7a4fe4f2f6c2-image.png

    I can work with that, I think :)

    thanks @sierdzio !


  • Moderators

    Thanks to you as well, for posting the solution. Maybe it will help somebody else, too :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.