QProcess not running command correctly & freezing gui



  • Hey,
    I know the basics of C++ but am a total QT noob so please treat me accordingly.
    This is the code in question:

    @void gamemode::on_gamemodeoff_clicked()
    {
    QProcess startagain;
    QString startCommand;
    startCommand = ("easystroke & synapse"); // for launching easystroke and synapse (2 programs)

    startagain.start(startCommand, QIODevice::ReadOnly);
    startagain.waitForFinished(-1);
    

    }
    @
    Whenever i run this and press the button my program only launches easystroke then freezes and doesn't launch synapse, what am i doing wrong?


  • Moderators

    Hi,

    Try ; instead of &. Because I think the second program won't launch until first completes. I'm not sure though.



  • Thanks for the response,
    If i use: @easystroke ; synapse@ the program does not freeze but still only launches easystroke.

    And if i use: @easystroke &; synapse@ it still only launches easystroke but then freezes.


  • Moderators

    Hi,

    Another way would be this
    @
    QProcess startagain;
    QString startCommand;
    startCommand = "easystroke";
    startagain.startDetached(startCommand);
    startCommand = "synapse";
    startagain.startDetached(startCommand);
    @

    This will work but there must be more elegant way.



  • Still only launches easystroke and freezes :(.


Log in to reply
 

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