Cannot retrieve debugging output in Qt Creator
Asked Answered
F

5

23

In Qt Creator on Windows, qDebug() statements don't work, and the following message appears in the output window:

Cannot retrieve debugging output.

How can it be fixed?

Fodder answered 17/1, 2013 at 12:38 Comment(1)
@FrankOsterfeld, on Windows.Fodder
F
49

This problem can show up if more than one instance of Qt Creator is active. To fix the issue, simply close all the other instances of Qt Creator and it should work.

Fodder answered 17/1, 2013 at 12:38 Comment(0)
M
3

Or you may be running a version of DebugView from Sysinternals, that causes the same result.

Maxey answered 13/8, 2013 at 12:16 Comment(1)
Exactly the cause for me ^_^Rabkin
G
3

For me, I solved the problem by simply closing the running application built with the other qt creator. So not necessary to close the other qt creator.

Grory answered 25/4, 2018 at 7:45 Comment(0)
H
2

Well, I had two instances of QtCreator and I could not close one of them. They work together. One workaround for this problem is redirecting your application output messages using qInstallMessageHandler.

#include "mainwindow.h"

#include <QApplication>

void redirectedOutput(QtMsgType, const QMessageLogContext &, const QString &);
QMutex debugOutMutex;

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication app(argc, argv);

    qInstallMessageHandler(redirectedOutput);
    
    MainWindow w;
    w.show();
    
    return app.exec();
}

void redirectedOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    debugOutMutex.lock();
    std::cout << QDateTime::currentDateTime().toString("hh.mm.ss.zzz  ").toStdString() <<  msg.toStdString() << std::endl;
    if (type == QtFatalMsg) {
        abort();
    }
    debugOutMutex.unlock();
}

I added a QMutex too. If your application is utilizing more than one thread, debug outputs can be mixed.

Harquebus answered 13/8, 2021 at 9:1 Comment(0)
P
1

For me this error message appears when I have more than one instance of my application, not of Qt Creator.

Plaid answered 18/1, 2013 at 7:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.