You are not logged in.

#1 2020-09-14 05:43:43

nasser
Member
Registered: 2016-01-23
Posts: 56

qDebug doesn't display anything in application output

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.

.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 undefined.

what I have tried:
include "QtDebug" instead of "qDebug"
create qtlogging.ini with content:-

    [Rules]
    *.debug=true
    qt.*.debug=false

Tried a clean build (clean and rebuild project) after each 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.

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

Offline

#2 2020-09-15 08:46:31

Anchorman
Member
Registered: 2020-07-26
Posts: 45
Website

Re: qDebug doesn't display anything in application output

That's weird! Do you get the same result if you load one of the Creator example projects and just add

#include <QDebug>

and

qDebug() << "test"; 

?

Last edited by Anchorman (2020-09-15 08:47:03)

Offline

Board footer

Powered by FluxBB