How to convert QString to int?

前端 未结 7 1971
执念已碎
执念已碎 2021-02-01 12:10

I have a QString in my sources. So I need to convert it to integer without \"Kb\".

I tried Abcd.toInt() but it does not work

7条回答
  •  春和景丽
    2021-02-01 12:46

    The string you have here contains a floating point number with a unit. I'd recommend splitting that string into a number and unit part with QString::split().

    Then use toDouble() to get a floating point number and round as you want.

提交回复
热议问题