How to convert string into const int ?
How to convert string into const int ?
Try this
Qt Code:
const int myInt=myString.toInt();To copy to clipboard, switch view to plain text mode
It works!
But strangely if I do it the way as shown in code below, I will get error: assignment of read-only variable myInt .
Qt Code:
const int myInt = 0; myInt = myString.toInt();To copy to clipboard, switch view to plain text mode
That is an expected behavior, since consts can be assigned value only once. In your case you use your one chance when you assign 0 to it. After that it become read-only.
Bookmarks