Qt QDebug does not work (does not display messages)

1

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

I'm trying to print messages on the console using qDebug () , but nothing is displayed . I've tried everything and nothing solves!

What should I do to set up qDebug ()?

    
asked by anonymous 28.04.2016 / 19:13

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 QDebug and QLoggingCategory header:

#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();
}
    
28.04.2016 / 19:13