qDebug dosen't print anything when using vscode

434 Views Asked by At

I tried to use VSCode to code Qt program,but function qDebug doesn't print anything in console when debugging a Qt program in VSCode.However it works correctly when using QtCreator.By the way,Qt program is built by cmake in vscode.

I tried to place qDebug() in different files to test but all failed.

1

There are 1 best solutions below

0
On

qDebug() is comparable to stderr, and I think it's not really what you are looking for. To print in a console application, if you really want to use Qt, you can do this (proposed on this answer):

QTextStream& qStdOut()
{
    static QTextStream ts(stdout);
    return ts;
}


qStdOut()<<"May the Force be with you.";