Important: Please read the Qt Code of Conduct -

qDebug doesn't stream anything

  • Hello;
    I have just start learning Qt using Qt Creator V4.13 and Qt V5.15.1, when I use qDebug(), qInfo(), qWarning() and qCritical() it doesn't show any thing in the application output.
    I have checked 'run in terminal' and then clean and rebuild project, it now runs with "qtcreator_process_sub" with the required output of qDebug.

    .pro file

    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    CONFIG += c++11
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    SOURCES += \
        main.cpp \
    HEADERS += \
    FORMS += \
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    MainWindow.h file

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui { class MainWindow; }

    class MainWindow : public QMainWindow

    MainWindow(QWidget *parent = nullptr);
    private slots:
    void addTask();

    Ui::MainWindow *ui;
    #endif // MAINWINDOW_H

    MainWindow.cpp file

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "QtWidgets/QPushButton"
    #include "QDebug"
    #include <iostream>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    connect(ui->addTaskButton, &QPushButton::clicked, this, &MainWindow::addTask);

    delete ui;

    void MainWindow::addTask()
    qDebug()<<"Debug button";
    qInfo()<<"Information output";
    qWarning()<<"Warning output";
    qCritical()<<"Critical output";

    I have spent two days searching on Google but it all the answers were about undefine QT_NO_DEBUG_OUTPUT but it's defined.
    what I have tried:
    include "QtDebug" instead of "qDebug"
    create qtlogging.ini with content:-


    Tried a clean build (clean and rebuild project) after each edit
    Arch Linux (System is up to date I have just updated it)
    V4.13 and Qt V5.15.1
    CMake V3.18.2
    Make V4.3
    QMake V3.1

  • @Nasser-Ahmed
    Everything works fine for me (without touching any qtlogging.ini, should that indeed have qt..debug=false, I don't know?), under Ubuntu with all distro-released Qts, I never compile.

    One thing: add your own qInstallMessageHandler(myMessageOutput) as per . All qDebug()/qInfo() etc. go via that. Does that even get hit for you? If it does you have some problem with the output; it it does not you have some problem with your qDebug()s etc., such as compiled to do nothing.

    Another small thing: your Qt include #include statements should all be #include <something-no-slash>, so:

    #include <QPushButton>
    #include <QDebug>

    Using your "s there could be a danger if it picking up something of your own instead of the Qt system one. Correct those as shown, just in case....

Log in to reply