You are not logged in.
Pages: 1
Topic closed
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
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
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
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.
Online
The question was about output in QtCreator, not in terminal. TS has mentioned it.
Offline
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?
Online
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.
The output of Qt installed from Qt Online Istaller:
The output of Qt installed from Repo:
Both kits are in Debug mode with default settings.
Last edited by MikePooh (2021-06-02 08:12:45)
Offline
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)
Online
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
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
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
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
Log from Qt Creator is redirected to systemd journal.
Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.
Offline
Have found that it is still the issue. The solution from @d_fajardo works fine
Offline
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
Don't necrobump.
Offline
Closing this old thread.
Offline
Pages: 1
Topic closed