Important: Please read the Qt Code of Conduct -

QProcess::readyReadStandardError on Qt4

  • Here's a snippet of my code. I am using a QProcess to launch a "bad" unix command. The "readyReadStandardError" signal is connected to a slot.

    On Qt5.6, this slot gets fired. But on Qt4.8, the slot isn't getting fired.

    Any ideas about what's going on?

    MyClass::MyClass() {
    m_process = new QProcess(this);
    connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput()));
    connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(onReadyReadStandardError()));

     QString cmd = "/bin/sh -c \"/bin/foo\"";


    void MyClass::onReadyReadStandardOutput() {
    std::cout << "Output Ready!!!" << std::endl;

    void MyClass::onReadyReadStandardError() {
    std::cout << "Error Ready!!!" << std::endl;

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should check the error code you get from the execution of your command.

  • Thanks!

    After m_process->waitForFinished()

    m_process->errorString() returns "Unknown error"
    m_process->exitCode() returns 127 (which is the unix return code for invalid commands)

    I am trying to read any errors in the slot and print them to a transcript window.
    Things work fine on Qt5.
    On Qt4, the error goes directly to the terminal that the Qt application is run from and the slot is never called.

  • Lifetime Qt Champion

    What version of Qt 4 ?

Log in to reply