Qt - Converting float to QString
This seems like it should be very simple, but I'm going through the docs and not seeing anything. I just need to convert a number that is represented as a float object into a QString object. I know there is the function QString::number() that can be used for other types like int and double, like so: int a = 1; QString b = QString::number(a);
...however this doesn't seem to work for float. Perhaps there is some way where it is converted first from float to another type, and then from that type to QString? If anyone has any ideas I'd appreciate it. Thanks!
float will auto-promote to double when needed
float pi = 3.14; QString b = QString::number(pi);
otherwise you can use setNum:
float pi = 3.14; QString b; b.setNum(pi);