qDebug not displaying anything

我的未来我决定 提交于 2020-05-28 13:44:26

问题


Often when I need to debug something it's easier to print something using qDebug() instead of debugging step-by-step using a debugger. The problem is that from time to time the output of qDebug() isn't displayed at all! The same with qWarning and qCritical. What's strange, it only occurs when running the project normally (Ctrl+R), while when debugging (F5) the output shows up.


回答1:


The solution is simple: add CONFIG += console to your .pro file and rebuild the whole project.




回答2:


Solution for me, As stated in https://bugzilla.redhat.com/show_bug.cgi?id=1227295#c10 was :

  1. look for qtlogging.ini in /etc/xdg/QtProject/ .
  2. edit the current (or create the file qtlogging.ini if missing)
[Rules]
*.debug=false

to

[Rules]
*.debug=true
qt.*.debug=false
  1. recompile and check!



回答3:


If you are running multiple instances of Qt Creator, qDebug does not work properly.




回答4:


My solution for this problem using

Windows 10 Education
Qt Creator (5.x)
Developing a Qt widget.

Problem:

So my issue was whenever I added a QDebug message it didn't show up in the application output although my code was 100% the same as in the tutorial and compiled fine.

Solution:

Right click on the file where you added the QDebug message, for me it was main.cpp. Click build. Press the green arrow on the bottom.

If this still doesn't work go to "Build"->"CleanAll", "Build"->"qMake" and go for the green arrow again.

Of course you have to #include <QDebug> and check that it is well spelled inside your code.




回答5:


In my case, it is somehow I forgot to click the 'Configure Project'. I am using QTCreator 4.11 and Qt5.14. When I create the project, I did not click on the 'Configure project' near the end of the creation process.




回答6:


Qt5.14.2, QtCreator 4.12.0: What worked for me was to unselect Projects->Run->Run in Terminal... Duh!



来源:https://stackoverflow.com/questions/12799653/qdebug-not-displaying-anything

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!