I want to convert QString to short.when I try this code
It works well for text = 20 but it returns "0" for value = 20.5.
but I need value = 20. how can I solve it?Answer1:
The reason that 0 is returned is because a decimal point is an invalid character for the
short data type.
If you want to be able to convert floating-point numbers from
QString to integers, you need to convert your text to a
double first, then use normal rounding/truncation to convert to
use that convertion string: