Qt Qdebug does not work (does not display messages)

Asked

Viewed 87 times

1

I own the Fedora 23 operating system and use Qt to develop graphical interfaces (GUI), however my Debugger does not work:

I’m trying to print messages on console using qDebug(), but nothing is displayed. I’ve tried everything and nothing can fix it!

What should I do to fix qDebug()?

1 answer

1

Very simple! qDebug() messages have been disabled by default in Fedora. To enable them, you must add the following line of code to your program:

QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);

Remembering that your code should also include the headerer Qdebug and Qloggingcategory:

#include <QApplication>
#include <QLoggingCategory>

int main(int argc, char *argv[]){
    QApplication a(argc, argv);
    QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);

    qDebug() << "FINALMENTE FUNCIONOU!";

    return a.exec();
}
  • But do you want to display on the QTIDE console or terminal? Because if it is terminal I think it should not be used qDebug().

  • Works on both!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.