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()));
    
            ui->TextEditResult->setTextColor(Qt::white);
            QCoreApplication::processEvents();
    

    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)
        {
            proc->terminate();
           // Messagebox that QProcess has just terminated. (kill)
           ....
           ....
           ....
    
          // Do other job
        }
    

  • Moderators



  • @jsulm Thank you... :)


Log in to reply
 

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