Unable to see the QDebug Messages on console.



  • Hi,
    Recently i have started to program and compile with Qt-5.7.1. I have successfully compiled for desktop and compiling and execution everything is fine. But the problem is i am unable to see the debug messages on the linux console, i am not getting where i did mistake or is anything more need to be added while compiling qtsource specially in order to see the qdebug messages on console.

    Help me to resolve my problem.

    Thanks in advance,
    Rohith.G



  • can you share your .pro file .



  • @yuvaram

    Hi Yuvaram thanks for replying, here is my .pro file please check it out.

    TEMPLATE = app
    TARGET = CndM
    INCLUDEPATH += .
    QT+=  core widgets gui sql
    OUTPUT += Console
    # Input
    HEADERS += database.h widget.h
    FORMS += widget.ui
    SOURCES += database.cpp main.cpp widget.cpp
    


  • @Rohith ,

    Add,
    CONFIG += console



  • @Rohith
    You need to add CONFIG type in profile, as shown
    TEMPLATE = app
    TARGET = CndM
    INCLUDEPATH += .
    QT+= core widgets gui sql
    CONFIG += console

    Input

    HEADERS += database.h widget.h
    FORMS += widget.ui
    SOURCES += database.cpp main.cpp widget.cpp



  • @yuvaram

    Hi yuvaram and vijay thanks for replying, i have tried as per your suggestion but no use i am unable to see the qdebug messages.

    my new .pro file

    TEMPLATE = app
    TARGET = CndM
    INCLUDEPATH += .
    
    QT+= core widgets gui sql
    CONFIG += console
    
    # Input
    HEADERS += database.h widget.h
    FORMS += widget.ui
    SOURCES += database.cpp main.cpp widget.cpp
    


  • @Rohith
    you'll have to rerun qmake after changes in your *.pro file



  • @J.Hilk

    Hi Hilk thanks for replying, i have recompiled the project from start i.e
    i have done
    makedistclean
    qmake -project
    added all the inputs
    qmake
    make



  • @Rohith
    Try to delete build folder , then try clean, qmake, build, run



  • @yuvaram

    Hi Yuvaram,

    There is no separate build folder for my project, i am compiling through command line.
    What is your intention i am following the same thing i am doing i.e fresh compilation, but still unable to see the messages.



  • @Rohith ,

    Try compiling your code through Qt Creator, and check the qDebugs in application output?



  • Hi, also, as a workaround, you can capture all qDebug messages and print them out yourself, just call qInstallMessageHandler, say like this:

    #include "stdio.h"
    void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
    {
        printf(qUtf8Printable(msg));
        printf("\n");
    }
    
    int main(int argc, char *argv[])
    {
        qInstallMessageHandler(messageHandler);
    
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    

Log in to reply
 

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