c++ - How to print to console when using Qt -


i'm using qt4 , c++ making programs in computer graphics. need able print variables in console @ run-time, not debugging, cout doesn't seem work if add libraries. there way this?

if enough print stderr, can use following streams intended debugging:

//qinfo qt5.5+ only. qinfo() << "c++ style info message"; qinfo( "c style info message" );  qdebug() << "c++ style debug message"; qdebug( "c style debug message" );  qwarning() << "c++ style warning message"; qwarning( "c style warning message" );  qcritical() << "c++ style critical error message"; qcritical( "c style critical error message" );  // qfatal not have c++ style method. qfatal( "c style fatal error message" ); 

though pointed out in comments, bear in mind qdebug messages removed if qt_no_debug_output defined

if need stdout try (as kyle strand has pointed out):

qtextstream& qstdout() {     static qtextstream ts( stdout );     return ts; } 

you call follows:

qstdout() << "std out!"; 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -