Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Busy Cursor in window started by QProcess



  • Hi,
    I'm wondering what could make the cursor of a widget busy for while, if it started using QProcess. For example, let's say that I have a showWidget.exe executable that shows a simple widget like this:

    #include <QApplication>
    #include <QtWidgets/QWidget>
    
    int main(int argc, char *argv[])
    {
       QApplication a(argc, argv);
    
       QWidget w;
       w.show();
    
       return a.exec();
    }
    

    And in an other process I do :

     QProcess p;
     p.start(".../showWidget.exe"); 
     p.waitForFinished(-1);
    

    The shown widget gets a busy cursor for a while. That's it.
    It's not a big issue, but I just want to know if that can be fixed, because if I use the CreateProcess and WaitForSingleObject, win apis, there's no busy cursor.
    Thanks for your help.


  • Lifetime Qt Champion

    Hi,

    What do you mean by "in another process" ?



  • I mean from an other program. I'm not running that code in showWidget.exe.


  • Lifetime Qt Champion

    @SamurayH

    p.waitForFinished(-1); should only be used in threads. connect a slot to the finished() signal if you don't use threads instead.



  • Solved.
    I didn't know about this. The first time I checked the docs about waitForFinished, it says :
    "This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread."
    And then I used to do like this :

    int main(int argc, char *argv[])
    {
        QProcess p;
        p.start(".../showWidget.exe"); 
        p.waitForFinished(-1);
        
       if(p.exitCode() != ...)
    //...
    
      return 0;
    }
    

    Thank you very much @aha_1980.


Log in to reply