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. Getting QProcess to send Signals...
Forum Updated to NodeBB v4.3 + New Features

Getting QProcess to send Signals...

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.7k 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.
  • ModelTechM Offline
    ModelTechM Offline
    ModelTech
    wrote on last edited by
    #1

    I have created a QWizardPage class, which has the following code in its constructor:

        Process = new QProcess(this);
        connect(Process, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(onRunning(QProcess::ProcessState)));
        connect(Process, SIGNAL(readyReadStandardOutput()), this, SLOT(onOutput()));
        connect(Process, SIGNAL(readyReadStandardError()), this, SLOT(onError()));
    

    I have overriden the QWizardPage::initializePage() function and the code of my version of this function includes the following line:

    Process->startDetached(Command);
    

    where Command is QString that represents what should be executed. I see that this execution does take place and it does produce some text on stdout. However, none of the signals QProcess::stateChanged(QProcess::ProcessState), QProcess::readyReadStandardOutput() and QProcess::readyReadStandardError() get triggered as the slots in my QWizardPage to which these signals are connected do not get executed when the Command is executed. Is there anything that I should do to activate the signalling or so?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      startDetached is a static method thus it doesn't use the Process object at all. Use start if you want to get something from your process.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • ModelTechM Offline
        ModelTechM Offline
        ModelTech
        wrote on last edited by
        #3

        Great! That solved it. Wasn't aware that startDetached is static...

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Well, the method documentation as well as QProcess's list of static methods are pretty clear.

          However, with Qt 5.10, there will be a new version of that method.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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