Skip to main content
Topic: Qt's qDebug() does not work as expected out of the box (Read 1398 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Qt's qDebug() does not work as expected out of the box

Hi all :-)

I noticed that qDebug() does not work as it should by default: It does not print strings, and it does not set newlines correctly.

After some internet search, I found out that this can be fixed by setting an environment variable:
Code: [Select]
export QT_ASSUME_STDERR_HAS_CONSOLE=1
does the trick.

Now I wonder why this happens (I didn't see this on Gentoo and Debian). In the following SO question: https://stackoverflow.com/questions/26295325/ , a user writes:
Quote
If you happen to run Arch Linux, which compiles Qt with the -journald option, all debug output is per default directed to the systemd journal (display with journalctl).
So … is this a bug or a feature?! ;-) Is Qt on Artix actually compiled with the  -journald option? If so: why? If not: what causes this?

Maybe, we can fix this to make qDebug() work out of the box?

Re: Qt's qDebug() does not work as expected out of the box

Reply #1
Our qt#_base packages are always built with -no-journald
artist

Re: Qt's qDebug() does not work as expected out of the box

Reply #2
Okay … so what causes the defective qDebug() output then? And why do I have to export that QT_ASSUME_STDERR_HAS_CONSOLE variable?

Don't get me wrong, no harm meant! I just want to help to make Artix better (as one would expect that qDebug() works out of the box, without any changes)!

Re: Qt's qDebug() does not work as expected out of the box

Reply #3
Are you sure you don't have packages from the arch repo, and you didn't build Qt yourself?

Actually, more importantly, Qt6 or Qt5?

I have a Qt 5.15.5 project, and I see debug output in the console. I'm not setting QT_ASSUME_STDERR_HAS_CONSOLE anywhere.


Re: Qt's qDebug() does not work as expected out of the box

Reply #4
This is  a fresh Artix install, withput any Arch repositories added. I also didn't build Qt myself. I see this using Qt 5.15 (qt5-base-5.15.5+kde+r174-1 etc. from world).

Re: Qt's qDebug() does not work as expected out of the box

Reply #5
Ah, well, sorry if I distracted, then. I don't have this variable in my entire /etc, in my home directory, or in my source anywhere (such as in a call to qputenv), and QDebug seems to work fine. (Even `qDebug() << qgetenv( "QT_ASSUME_STDERR_HAS_CONSOLE" );` just outputs `""`).

Other than possibly other people facing the same issue chiming in, perhaps you could post a project or something where this issue occurs.

Re: Qt's qDebug() does not work as expected out of the box

Reply #6
Well, you won't see this if you're not about to develop a Qt/KDE program – all qDebug calls are stripped out when creating a release build. So nobody will see this simply using some program.

I also don't think that this variable is exported somewhere else. On my Gentoo boxes (where this doesn't happen), QT_ASSUME_STDERR_HAS_CONSOLE isn't set anywhere, neither in /etc, nor in /usr or in any ~/ file.

Setting this is also probably not the correct approach, it only makes it work …