qDebug() doesn't show messages in Qt Creator/Application Output
-
Env
arch linux
KDE Plasma 6.5.3
Qt Creator 18.0.0
Qt 6.10.1Problem
Running in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running in a terminal manually, it shows.
Codes
#include <QDebug> int main() { qDebug() << "Test123"; qDebug() << "Test456"; return 0; } -
J jronald marked this topic as a regular topic
-
C Christian Ehrlicher moved this topic from General and Desktop
-
J jronald marked this topic as a question
-
Hi and welcome @jronald !
please addqInfo() << QT_VERSION_STR << QT_DEBUGand post the output here.
Cheers
Axel -
BTW, I have the impression that
main()doesn't get called at all.
That's because of a signature mismatch, probably.
Usually the function has this signature:int main(int argc, char *argv[]) -
BTW, I have the impression that
main()doesn't get called at all.
That's because of a signature mismatch, probably.
Usually the function has this signature:int main(int argc, char *argv[])@Axel-Spoerl In principle you are right, but I don't think thats the problem here.
int main()is even the default in the C++ template in Creator and that works.Interesting though, what happens under the hood so the linker does not complain.
Regards
-
I would guess there is an external logging config somewhere. Please read https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories
-
I would guess there is an external logging config somewhere. Please read https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories
@Christian-Ehrlicher
To be fair the OP reportsRunning in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running a terminal manually, it shows.
Assuming the executable is compiled the same (e.g. either debug or release) whether it is run from Creator or from a terminal how would some "external logging config" allow for output to terminal in the latter case but not the former? Unless you mean the environment differs such that this logging file is picked up when running from Creator but not outside?
@jronald
You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference? -
Hi and welcome @jronald !
please addqInfo() << QT_VERSION_STR << QT_DEBUGand post the output here.
Cheers
Axel@Axel-Spoerl said in qDebug() doesn't show messages in Qt Creator/Application Output:
Hi and welcome @jronald !
please addqInfo() << QT_VERSION_STR << QT_DEBUGand post the output here.
Cheers
Axel#include <QDebug> #include <QtVersion> int main() { #ifdef QT_DEBUG qDebug() << "Test123"; qInfo() << QT_VERSION_STR; #else qDebug() << "Test456"; qInfo() << QT_VERSION_STR; #endif return 0; }can't output
QT_DEBUGas QT_VERSION_STR does, so do it as above.
Still no output in "Qt Creator/Application Output", but when run it in a terminal manually, it outputs as below:Test123 6.10.1 -
@Christian-Ehrlicher
To be fair the OP reportsRunning in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running a terminal manually, it shows.
Assuming the executable is compiled the same (e.g. either debug or release) whether it is run from Creator or from a terminal how would some "external logging config" allow for output to terminal in the latter case but not the former? Unless you mean the environment differs such that this logging file is picked up when running from Creator but not outside?
@jronald
You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?@JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:
You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?
I've tried debug only.
I tried release just now, same as debug, no output in "Qt Creator/Application Output", output in a terminal. -
It works after adding
QT_ASSUME_STDERR_HAS_CONSOLE=1in "Projects/Run Settings/Environment".
But I don't know why.https://bbs.archlinux.org/viewtopic.php?id=259035
Log from Qt Creator is redirected to systemd journal.
Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.I've checked
journalctl, the outputs are there.
It should be the cause of archlinux, not intuitive, and leaves unnecessary footprints. -
https://bbs.archlinux.org/viewtopic.php?id=259035
Log from Qt Creator is redirected to systemd journal.
Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.I've checked
journalctl, the outputs are there.
It should be the cause of archlinux, not intuitive, and leaves unnecessary footprints. -
J jronald has marked this topic as solved
-
@jronald
That looks like it to me for Arch, well found! I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.@JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:
I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.
It's the default behaivor of Qt to output to journelctl on linux, https://doc.qt.io/qt-6/qtlogging.html#qDebug
qDebug(const char *format, ...) Logs debug message format to the central message handler.I think ubuntu has changed this in a good way.