Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How do I know that QProcess has finished?

    Mobile and Embedded
    2
    3
    2370
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      NTCYP last edited by NTCYP

      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
          }
      
      1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion last edited by

        Use the finished signal: http://doc.qt.io/qt-5/qprocess.html#finished

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        N 1 Reply Last reply Reply Quote 0
        • N
          NTCYP @jsulm last edited by

          @jsulm Thank you... :)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post