How to convert QString to int?
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. QString Abcd = "123.5 Kb" You don't have all digit characters in your string. So you have to split by space QString Abcd = "123.5 Kb"; Abcd.split(" ")[0].toInt(); //convert the first part to Int Abcd.split(" ")[0].toDouble(); //convert the first part to double Abcd.split(" ")[0].toFloat(); //convert the first part to float Update : I am updating an old answer. That was a straight forward answer to the specific question, with a strict assumption. However as noted by