Using printf in Qt Creator app
-
Hello,
Since I mostly do embedded C, I am really used to using printf to write out debug messages and such, including all the number formatting it offers. Can easily use printf in my Qt Creator app to write to a text control or the Application Output window? If I just simply run printf("hello\n") etc, such as in a pushButton_clicked slot, I do not see the output while the app is running. Only after I exit the app, the output appears in the Application Output. Can I make it appear immediately?
Thanks
Ron -
I have an answer to my own question. I just happened to see an example of this used in the help. You use qDebug() as if it were printf():
qDebug( "the integer is: %d", 12345 );
Thanks
Ron -
Also you can use it in C++ stream way
@
qDebug() << "the integer is" << 777;
@
qDebug() will add spaces between parts of a mesage and add eol character. -
The first answer contains your options but the second answer here is most informative:
http://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-strin -
Thanks folks