Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert int to QString?

Is there a QString function which takes an int and outputs it as a QString?

like image 712
Ahmad Avatar asked Jul 09 '10 10:07

Ahmad


People also ask

How do you convert QString to string?

You can use: QString qs; // do things std::cout << qs. toStdString() << std::endl; It internally uses QString::toUtf8() function to create std::string, so it's Unicode safe as well.

How do you convert int to string manually?

Conversion of an integer into a string by using to_string() method. The to_string() method accepts a single integer and converts the integer value or other data type value into a string.

How do I convert an int to a string in C ++?

The next method in this list to convert int to string in C++ is by using the to_string() function. This function is used to convert not only the integer but numerical values of any data type into a string. The to_string() method is included in the header file of the class string, i.e., <string> or <cstring>.


1 Answers

Use QString::number():

int i = 42; QString s = QString::number(i); 
like image 148
Georg Fritzsche Avatar answered Oct 14 '22 23:10

Georg Fritzsche