Maybe something like this:
int val = 123;
int rest;
int digit;
rest=val;
QVector<char> v;
while(rest>0){
digit = rest % 10; // last digit
rest = rest / 10;
v.push_front(digit+'0');
}
int val = 123;
int rest;
int digit;
rest=val;
QVector<char> v;
while(rest>0){
digit = rest % 10; // last digit
rest = rest / 10;
v.push_front(digit+'0');
}
To copy to clipboard, switch view to plain text mode
Then if you want their hex value, just sprintf them with "%x" formatting, like:
for(QVector<char>::const_iterator it = v.begin(); it!=v.end(); ++it){
::snprintf("%x", *it);
qDebug(qPrintable(hex));
}
for(QVector<char>::const_iterator it = v.begin(); it!=v.end(); ++it){
::snprintf("%x", *it);
qDebug(qPrintable(hex));
}
To copy to clipboard, switch view to plain text mode
Of course you can use QString::arg() for that.
You can also use QString methods directly like so:
int val = 123;
for(int i=0;i<text.size();i++){
hex <<
QString::number(text
[i
].
toAscii(),
16);
}
int val = 123;
QString text = QString::number(val);
QStringList hex;
for(int i=0;i<text.size();i++){
hex << QString::number(text[i].toAscii(), 16);
}
To copy to clipboard, switch view to plain text mode
Bookmarks