1

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.

Rascal
  • 11
  • 1
  • 1
    Which operating system? – Violet Giraffe Jan 07 '23 at 09:02
  • windows 11. ... – Rascal Jan 08 '23 at 05:41
  • `qDebug()` is printing to a special destination called "debug output", it's not `stdout` nor `stderr`. This output is usually received by the debugger when it's attached to the running process. Are you running with a debugger attached? If you do, there should be an output window that shows `qDebug()` output. There is also a free application from Microsoft called "DebugView" that displays system-wide debug output in real time. – Violet Giraffe Jan 08 '23 at 08:50

1 Answers1

0

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.";