1. It is very simple to convert QString type to float type.
QString data;
float num = data . to float();
This is easy to achieve.
2. But how do you convert a float type into a QString type?
It is difficult to find the encapsulated conversion function by looking at the API.
You can try the following transcoding:
Floating point number =1.222;
QString data = QString("float is% 1 "). arg(num);
The output result is: float is 1.222.
If only float is converted to a numerical value, use the following:
QString data = QString("% 1 ")。 arg(num);