toFloat () should work. Make sure your string contains only the number. If the string contains something else, for example, "144.2e-3 a"then toFloat () returns 0. Note that other numbers in the string will result in conversion failure, for example, it QString("144.2e-3 100").toFloat()will return 0.
Additional spaces in the numeric string do not matter, but other characters.
user362638
source
share