toFloat() should work. Check that your string contains only the number. If the string contains something else too, for example "144.2e-3 a"
, then the toFloat() returns 0. Note that also other numbers in the string will cause the conversion to fail, for example QString("144.2e-3 100").toFloat()
will return 0.
Additional whitespace in the number string doesn't matter, but other characters do.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…