PDA

View Full Version : how to print a value in qt



qt_user
6th August 2010, 10:22
I want to print the value of a variable(integer) on (say) a label in Qt.......
How can i do it??

saa7_go
6th August 2010, 10:36
You can convert integer type to QString type using QString::number() (http://doc.trolltech.com/4.6/qstring.html#number-4).

qt_user
6th August 2010, 11:26
thanx a lot.....can I also do something like "stament to be printed " variable1 "more statments" variable2.............. as in C language??

saa7_go
6th August 2010, 12:37
You can look at http://doc.trolltech.com/4.6/qstring.html#arg.

Lykurg
6th August 2010, 14:42
or simple use + to concat strings

squidge
6th August 2010, 21:17
thanx a lot.....can I also do something like "stament to be printed " variable1 "more statments" variable2.............. as in C language??

No, and thats not C language (unless variable1 and variable2 are #define's containing text)

But you can do:



QString temp = "stament to be printed " + variable1 + "more statments" + variable2;


Assuming variable1 and variable2 and also QString's.