Laman

Monday, September 19, 2011

How To Sending Message To Terminal Using qDebug and qWarning

Sometimes, the developer need to sending a message or more in a string form to the terminal to inform what happening is/was going on. It could be the error messages, the state of the program flowchart, warning messages or whatever kinds of message.

The advantage of sending message in string format to the terminal is no need GUI to show it and let's you monitor how your program flows. Thus, you can use command to sending a message to terminal. And you can see your message by starting your application you've made from terminal.

This is very easy and simple thing in Qt programming.

qDebug :
qDebug("Your message");

or you can use a QString variable like this :
QString s;
s="Your message";
qDebug(s);

qWarning :
qWarning("Your message");

or you can use a QString variable like this :
QString s;
s="Your message";
qWarning(s);
See also Qt Tutorial about :

Search newest article here :