Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The second QProccess is not running.
Forum Updated to NodeBB v4.3 + New Features

The second QProccess is not running.

Scheduled Pinned Locked Moved General and Desktop
qprocess
5 Posts 4 Posters 1.5k Views 2 Watching
  • 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.
  • F Offline
    F Offline
    ForestPoem
    wrote on last edited by
    #1

    Hi.

    The second QProccess is not running.

    my source code.
    qProc = new QProcess;
    qProc->start("ifconfig"); <--running
    qProc->start("route"); <--not running.

    how to second command running?

    jsulmJ ValentinMicheletV 2 Replies Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

      Did you check if any of the process returned an error?

      What do you want to achieve with the ifconfig process? If you want to configure the connection, then you're a) missing arguments, 2) the configuration may not be complete when the "route" command is started.

      Beware that "Note: Processes are started asynchronously, which means the started() and error() signals may be delayed. Call waitForStarted() to make sure the process has started (or has failed to start) and those signals have been emitted." taken from the the doc.

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • F ForestPoem

        Hi.

        The second QProccess is not running.

        my source code.
        qProc = new QProcess;
        qProc->start("ifconfig"); <--running
        qProc->start("route"); <--not running.

        how to second command running?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @ForestPoem Do you really use the same QProcess instance to start the second process?!
        If so - do you wait until the first process finished?
        You can call qProc->state() to check the state of the process.

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

        1 Reply Last reply
        0
        • JohanSoloJ Offline
          JohanSoloJ Offline
          JohanSolo
          wrote on last edited by
          #4

          @jsulm I missed the same instance was used twice! I need one more coffee to wake up ;-)

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          1 Reply Last reply
          0
          • F ForestPoem

            Hi.

            The second QProccess is not running.

            my source code.
            qProc = new QProcess;
            qProc->start("ifconfig"); <--running
            qProc->start("route"); <--not running.

            how to second command running?

            ValentinMicheletV Offline
            ValentinMicheletV Offline
            ValentinMichelet
            wrote on last edited by ValentinMichelet
            #5

            @ForestPoem
            First, you have to understand that QProcess is running asynchronously. That means that in your two lines containing a start call, your second start is not waiting for the first process to stop.

            QProcess has some handful signals that tell you what it's doing:
            http://doc.qt.io/qt-5/qprocess.html#signals

            In particular, you have the finished signal that tells you when the process is done. From that you can connect a slot that will start your second process, here the "route" process.

            If you have a lot of processes to run in a row, I think you could add them to a QQueue member variable. Then, connect your QProcess finished signal to a custom slot that will start the next process until the QQueue is empty. You can also handle errors and decide what to do if anything wrong happens.

            If you want some code example, what you try to achieve is close to this:
            http://doc.qt.io/qt-5/qtnetwork-downloadmanager-example.html

            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