Answer the question
In order to leave comments, you need to log in
Why doesn't qDebug work in other calls?
Good time!
For some reason, qDebug does not work in calls after the first line of the main body of the code.
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
qDebug() << "1 start" ;
QApplication a(argc, argv);
qDebug() << "2 start" ;
MainWindow w;
qDebug() << "3 start" ;
w.show();
return a.exec();
}
1 start
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = gui_project
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
myclass.cpp
HEADERS += mainwindow.h \
myclass.h
FORMS += mainwindow.ui
Answer the question
In order to leave comments, you need to log in
I had the same situation. Additionally, it turned out that std::cout behaves similarly, but qWarning() is quite efficient.
The decision found at one foreign forum helped. Successfully worked in my installation with qt.io.
You need to create a file ~/.config/QtProject/qtlogging.ini
And yes, Ubuntu OS.
I bet it will work if you put it after the line QApplication a(argc, argv); ?
I did not find an explicit explanation in the documentation, but I suspect that its work is somehow tied to event loops and, as a result, you need an event loop (i.e. either QApplication or QCoreApplication)
And why did you decide that it is not displayed? Start the console, run your application from the console and check that everything is output. Windows, did I guess correctly?
qDebug has stopped working in recent versions of gdb. If you just run it in the console without a debugger, it will work.
https://sourceware.org/bugzilla/show_bug.cgi?id=18164
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question