Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How do I know that QProcess has finished?
Forum Updated to NodeBB v4.3 + New Features

How do I know that QProcess has finished?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 2.8k Views
  • 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 Offline
    N Offline
    NTCYP
    wrote on last edited by NTCYP
    #1

    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
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • jsulmJ jsulm

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

        N Offline
        N Offline
        NTCYP
        wrote on last edited by
        #3

        @jsulm Thank you... :)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved