Hi,
Does anybody know how to convert "-2" string to integer?
I have tried doing it as follows but no success....
Is there anything wrong with the following code???
QString s = "-2";
bool ok;
uint m = s.toUInt( &ok, 10 );
Thank you for any help...
Hi,
Does anybody know how to convert "-2" string to integer?
I have tried doing it as follows but no success....
Is there anything wrong with the following code???
QString s = "-2";
bool ok;
uint m = s.toUInt( &ok, 10 );
Thank you for any help...
We figured out how to do it....Here it goes....
QByteArray bArray = s.toLatin1();
const char * ch = bArray.constData();
int m = atoi(ch);
If there is anyother way your welcome to let me know...
Thanks....
Originally Posted by mgurbuz
How about asking for and storing the result in a signed integer aswell?Originally Posted by mgurbuz
Qt Code:
int m = s.toInt( &ok, 10 );To copy to clipboard, switch view to plain text mode
J-P Nurmi
Tell me, how would you like to store a negative number as an unsigned integer?As 2^32 - 2?
Or maybe 2^31? AFAIK -2 is a signed integer...
Allright I got it....
I was tried and didn't really read what I wrote....
and tried many things at that time from toUInt ... to... toInt
couldn't make it work.
My question was how to convert a string to signed integer
and as an expert you understand it perfectly....
Originally Posted by wysota
Bookmarks