views:

383

answers:

2

I want to "stringify" a number and keep leading zeros. Unlike this question:

http://stackoverflow.com/questions/885401/print-trailing-zeros-in-a-qstring

I also need this in hex. By code now uses this, which is not enough:

QString::number(myNumber,16).toUpper()
+3  A: 

Try:

QString number = QString("%1").arg(yourNumber, 8, 16, QChar('0')).toUpper();
chalup
A: 

I was trying this (which does work, but cumbersome).

QString s;
s.setNum(n,base);
s = s.toUpper();
presision -= s.length();
while(presision>0){
    s.prepend('0');
    presision--;
}
elcuco