Important: Please read the Qt Code of Conduct -

QProcess in different thread does not send readyRead() signal (whole concise code pasted)

  • I have a worker object in separated thread, launching QProcess command within this same thread, but the slot processCommandOutput is never triggered.

    So the question is : it looks the readyRead() signal is never triggered, but if I call worker in the same thread of MainWindow, everything is fine.

    When I replaced the 'start' with 'execute' for the QProcess object workProcess, I can see the command output in the IDE command output window, e.g., Qt Creator Application Output.

    I don't see any error in this multi-thread programming because it is so short and straightforward, and I don't see any warning message in my Qt Creator.

    I'm using Qt4.8.

    void MainWindow::processInputCommand() {
        // Give QThread ownership of Worker Object
        QThread *thread = new QThread;
        // Connects the thread’s started() signal to the process() slot in the worker, causing it to start.
        connect(thread, SIGNAL(started()), activeWorker, SLOT(process()));
    Worker::Worker(QObject *parent) :
        workProcess = new QProcess(this);
    void Worker::setCommand(const QString &cmd) {
        cmdToRun = cmd;
    void Worker::process() {
        connect(workProcess, SIGNAL(readyRead()), this, SLOT(processCommandOutput()));
        workProcess->start(cmdToRun);          // if I use execute here, I can see command output in QtCreator Application Output
        emit finished();
    void Worker::processCommandOutput() {
        qDebug() << "GOGO";
        QString sz = QString(workProcess->readAllStandardOutput());
        emit outputDataReady(sz);

  • @qt_fan_4k Hi!
    QProcess::start() starts the process asynchronously. So in the following snippet...

    emit finished();

    The finished() signal is emitted immediately after the start() call and thus it depends only on your luck if the started process 1) has already been started and 2) has already finished. See:

  • @Wieland
    Thank you so much, Wieland. You're 100% right, and I was not lucky enough :)
    After moving the sending of finish signal elsewhere, everything goes fine.