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.
[Edit]
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 \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui TRANSLATIONS += \ ToDo_ar_EG.ts # 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>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACEclass MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void addTask();private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_HMainWindow.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)
{
ui->setupUi(this);
connect(ui->addTaskButton, &QPushButton::clicked, this, &MainWindow::addTask);
}MainWindow::~MainWindow()
{
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:-
[Rules]
.debug=true
qt..debug=falseTried a clean build (clean and rebuild project) after each edit specs: 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 anyqtlogging.ini
, should that indeed haveqt..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 https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler . AllqDebug()
/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 yourqDebug()
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....