didnt work?
dont know what you mean.
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <QtCore/QCoreApplication>
#include <QString>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString seven = "111";
bool b;
int x = seven.toInt(&b, 2);
qDebug() << b << x;
return a.exec();
}
|
true 7
That is correct behaviour. If you want int to mean something that isnt int, then, well, thats your problem :p
Please state what is your input, and what is your desired output.
From your op you have input as 'hex string'. You state you can convert that into binary string already, so you dont want that. You then seem to be trying to convert the binary string into a number. Well, you can convert the hex string into the same number without converting it to binary string first. I played along anyway, and showed you how to get the int from a 'base two string val' (int is int, not int base 10, or int base 2). But that is not right, apparently.
So what do you actually want to do?
NB
in c++
int w = 1.1e1; x = 0xb; int y = 013; int z = 11;
all have the same value: 11. If you want 11 to look like 1011, then it is just a matter of representation and you are back to changing a number into a string.