1

I have a problem with the debug feed in QtCreator, it keep spamming newline caracters.

If I remove all qDebug() call in my code it works fine and output nothing. But if call qDebug once (like qDebug() << "test"; at the start of main for example) it will keep spamming newline in the output feed after that call until I close my app.

output

main.cpp

#include "mainwindow.h"
#include <QApplication>
#include <QtDebug>

int main(int argc, char *argv[])
{
    qDebug() << "test";

    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Le Moisso
  • 11
  • 2
  • 1
    hmm, maybe you should provide a simple code example ;) because i have no idea what you are trying... – retinotop Oct 23 '18 at 14:21
  • 2
    Welcome to Stack Overflow! Please **[edit]** your question with an [mcve] or [SSCCE (Short, Self Contained, Correct Example)](http://sscce.org) – NathanOliver Oct 23 '18 at 14:21
  • I've used `qDebug()` often in a similar manner like exposed in your sample code but without the effect you describe. (on Windows and in cygwin/X11/Windows) Are you sure that there is not another call of `qDebug()` somewhere in the `MainWindow` code (which you didn't expose)? On what system do you run your sample? – Scheff's Cat Oct 23 '18 at 15:24
  • Yes, i'm sure there are no other qDegug call in MainWindow. At least not in the code I wrote. could there be some call, in the code generated buy qtCreator when designing ui, that I can't see ? I'm running on windows with Qt_5_11_2_MinGW_32bit – Le Moisso Oct 23 '18 at 15:40
  • Try using [`qInstallMessaeHandler()`](http://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler) for troubleshooting this. I for one have never encountered this, it sounds rather strange. – hyde Oct 23 '18 at 19:19
  • Another thing to try is, replace your own `MainWindow` instance with plain empty `QWidget` instance, and see if that stops the problem. – hyde Oct 23 '18 at 19:20

1 Answers1

0

You can turn on much better diagnostic information with qDebug() [and related qWarn() and qFatal()] that may help you find the problem. It is done using the qSetMessagePattern(..) function.

Try inserting this at the top of main(), then run a Debug build and see what happens. It should output the function, file, and line where each qDebug() call is made.

// set logging stuff
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss.zzz} | %{function} [%{file}(%{line})] | %{message}");
jwernerny
  • 6,978
  • 2
  • 31
  • 32
  • Thanks, I added it but i keep geting newline, without the time and function (I only get it for the "test" call). Also, i realised it only spam newline in execution mode, and not in debug mode. – Le Moisso Oct 23 '18 at 17:09