Important: Please read the Qt Code of Conduct -

How do I know that QProcess has finished?

  • Hi,

    In my app I connect to wifi hotspot. And I use ping option to check if the connection is okay as shown below code?

    // Create QProcess object
            proc = new QProcess();
            proc->start("ping", QStringList() << "-c" << "3" << QString(m_sHostName));
            // Show output
            connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(rightMessage()));
            connect(proc, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage()));

    Now I need to know if the QProcess has finished. If finished I have another job to do.
    So can I use below code to terminate my QProcess before doing another job?

        if(proc->waitForFinished(3) == true)
           // Messagebox that QProcess has just terminated. (kill)
          // Do other job

  • Lifetime Qt Champion

  • @jsulm Thank you... :)

Log in to reply