Qt debug feed keep spaming newline

223 Views Asked by At

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();
}
1

There are 1 best solutions below

1
jwernerny On

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}");