In QCoreApplication and QProcess

I am on my way to write a QCoreApplication which should create an external process via Qprocess.

I just noticed that even if the waitForStarted()

process state is called Running

before the event handler is executed, the external process is not started until the method is called on QCoreApplication exec()

.

That said, is it possible to defer the execution of the subroutine to trigger event handling (in which the QProcess needs to be instantiated), or the only viable way is to create a disposable QTimer?

0


source to share


1 answer


After a short investigation, the QCoreApplication :: processEvents () method is issued , which handles any pending events for the calling thread. In the following code

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    QProcess abc(....);
    abc.start(...);

    app.processEvents();

    //////////////////////////////////////////////////////
    // is the process really running ? //
    //////////////////////////////////////////////////////

    return  app.exec();
}

      



this method is required for the partition to be able to start the abc process. Otherwise abc will run when the event loop handles the start event. is-the-process-really-running

+1


source







All Articles