PDA

View Full Version : Problem with Qtextedit format - hex viewing



daro21
6th June 2011, 12:00
Hello.
I have a big problem. I try do a hex editor, and i don't know how format a text in Qtextedit. I would like it will look like this:

1000 0000 AA 65 34 5B 43 66 4B 56 89 D0 E1 .A....B.6.5.3

Could you tell me how i can format Qtextdocument ??

Santosh Reddy
6th June 2011, 20:18
One the possible ways, is to format your data before you add into QTextDocument / QTextEdit


QString str;
str = QString("Decimal 63 is %1 in hexadecimal")
.arg(63, 0, 16);
// str == "Decimal 63 is 3f in hexadecimal"

QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
str = QString("%1 %L2 %L3")
.arg(12345)
.arg(12345)
.arg(12345, 0, 16);
// str == "12345 12,345 3039"