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: 49
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

#3 2021-06-01 07:23:46

MikePooh
Member
Registered: 2021-06-01
Posts: 3

Re: qDebug doesn't display anything in application output

I have had the same issue when used Qt installed from Arch Linux repo. After that I've tried to install Qt from Qt online installer via Qt Maintanence Tool. The problem had gone.

Offline

#4 2021-06-01 11:17:49

seth
Member
Registered: 2012-09-03
Posts: 23,866

Re: qDebug doesn't display anything in application output

Don't necrobump.
Also that's nonsense.

#include <QDebug>
int main(int argc, char **argv) {
    qDebug() << "blahfoobar";
}
g++ -o qdebug -fPIC -I/usr/include/qt -I/usr/include/qt/QtCore -lQt5Core qdebug.cpp

works exactly as expected,

 local/qt5-base 5.15.2+kde+r196-1 (qt qt5)
      A cross-platform application and UI framework

Qt has lost more than one step since the Trolls sold it, but it's not *that* shit. Yet.

Offline

#5 2021-06-02 07:18:13

MikePooh
Member
Registered: 2021-06-01
Posts: 3

Re: qDebug doesn't display anything in application output

The question was about output in QtCreator, not in terminal. TS has mentioned it.

Offline

#6 2021-06-02 07:45:21

seth
Member
Registered: 2012-09-03
Posts: 23,866

Re: qDebug doesn't display anything in application output

OP buringly wrote:

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.

Sorry, missed that.

However, I just tried and despite being a really cumbersome way to some code, a test project

#include <QtDebug>
int main(int argc, char *argv[])
{
    qDebug() << "snafu";

}

works and prints the expected output in the 3rd console/tab thing on the bottom.
Did you try the OPs test project or a basic dummy?

Offline

#7 2021-06-02 08:07:20

MikePooh
Member
Registered: 2021-06-01
Posts: 3

Re: qDebug doesn't display anything in application output

I've tried the very basic project close to your code.

#include <QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    qDebug() << "qDebug";
    qWarning() << "qWarning";
    qCritical() << "qCritical";
    qFatal( "qFatal" );
    return a.exec();
}

And I have 2 versions of Qt installed in my system - first one called "Desktop" is installed from Arch Linux Repo and second one called "Desktop Qt 5.15.2 GCC 64 bit" is installed from Qt Online Installer.
0c49efcff4dd.png
d3eb27989c65.png

The output of Qt installed from Qt Online Istaller:
4c0352f00483.png

The output of Qt installed from Repo:
898fa0b7afd3.png

Both kits are in Debug mode with default settings.

Last edited by MikePooh (2021-06-02 08:12:45)

Offline

#8 2021-06-02 08:32:54

seth
Member
Registered: 2012-09-03
Posts: 23,866

Re: qDebug doesn't display anything in application output

Prints, but interestingly all lines are red - even if I comment the qFatal.

I assume something in the local Qt config redirected qdebug into stderr.
So I added "printf("snafu\n");" and that does indeed not show up.
fprintf(stderr, "snafu error\n"); however does.

The settings allow me to join stdin and stdout what gets me the qdebug output in black, but the printf to stdout still doesn't show up.

=> https://thomas.trocha.com/blog/qt-creat … tput-view/
Seems to be a buffer problem.
"fflush(stdout);" would re-arrange the output depending on when you flush.
Edit: more confirmation, https://stackoverflow.com/questions/290 … -debugging

Is the alternative creator some kind of snapflatdocker image?

Last edited by seth (2021-06-02 08:33:43)

Offline

#9 2021-07-31 11:06:21

ctnguyenvn
Member
Registered: 2019-04-13
Posts: 1

Re: qDebug doesn't display anything in application output

To day, I have had the same issue.
but if i start qtcreator on terminal and qDebug() work fine. else start with .desktop or dmenu then qDebug() will not show to Application output.

Last edited by ctnguyenvn (2021-07-31 11:33:37)

Offline

#10 2021-08-20 23:45:06

audifaxdev
Member
Registered: 2020-07-02
Posts: 2

Re: qDebug doesn't display anything in application output

Same here, when started from the desktop shortcut, QtCreator doe not seem to display debugging output.

As ctnguyenvn pointed out, starting QtCreator from the terminal solves the issue.

Offline

#11 2021-08-21 06:48:50

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,266

Re: qDebug doesn't display anything in application output

This works for me: Qt creator > Tools > Options > Kits, select your kit, find Environment, click change and add

QT_ASSUME_STDERR_HAS_CONSOLE=1

Offline

#12 2021-08-22 01:40:20

audifaxdev
Member
Registered: 2020-07-02
Posts: 2

Re: qDebug doesn't display anything in application output

d_fajardo wrote:

This works for me: Qt creator > Tools > Options > Kits, select your kit, find Environment, click change and add

QT_ASSUME_STDERR_HAS_CONSOLE=1

That worked! Thanks!

Offline

#13 2021-09-17 02:57:45

caas
Member
From: Serbia
Registered: 2019-03-16
Posts: 2

Re: qDebug doesn't display anything in application output

Log from Qt Creator is redirected to systemd journal.
Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.

Offline

#14 2021-09-26 11:19:10

dviktor
Member
From: Moscow
Registered: 2015-10-18
Posts: 159

Re: qDebug doesn't display anything in application output

Have found that it is still the issue. The solution from @d_fajardo works fine

Offline

Board footer

Powered by FluxBB