Hey guys .. Just a simple question .. Is there an QString function which takes and int and outputs its QString form ?
+6
A:
Use QString::number()
:
int i = 42;
QString s = QString::number(i);
Georg Fritzsche
2010-07-09 10:33:03
+1
A:
And if you want to put it into string within some context, forget about + operator. Simply do:
int i = 13; QString printable = QString("My magic number is %1. That's all!").arg(i)
Kamil Klimek
2010-07-09 20:12:21
Very useful method! +1 for that.
Narek
2010-07-11 11:06:39
A:
I always use QString::setNum().
int i = 10;
double d = 10.75;
QString str;
str.setNum(i);
str.setNum(d);
setNum() is overloaded in many ways. See QString class reference.
Narek
2010-07-11 11:05:26