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_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void addTask();
private:
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)
{
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
Tried 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