QProcess readLine from qDebug()



  • Hi,
    i started a qt-based qProcess

    i connect connect(appProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandardOutput()));

    void AppControl::readStandardOutput()
    {
    while(m_trmAppProcess->canReadLine())
    {
    qDebug() << "fromAppProcess: " << m_trmAppProcess->readLine();
    }

    but this would not work properly.
    however i can see that the signal is emitted properly so i run into the readStandardOutput function.

    canReadLine() will return false.

    how can i get those messages?

    rgards



  • readyReadStandardError() is emitted when cerr has data. you need to call setReadChannel to specify you want to read from cerr and not cout.

    void AppControl::readStandardOutput()
    {
    m_trmAppProcess->setReadChannel(QProcess::StandardError);
    while(m_trmAppProcess->canReadLine())
    {
    qDebug() << "fromAppProcess: " << m_trmAppProcess->readLine();
    }
    }



  • Thank You. That worked!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.