Display hexdecima format
-
Hi all.
I want to display the string entered in lineEdit_1 in hexadecimal format in LineEdit_2.
For example, if I enter 12AB, yI want to display 31 32 41 42.What should I do?
Thank you.
Hi @taku-s,
just to add an example to @ChrisW67's good hints:
lineEdit_2->setText(lineEdit1->text().toLocal8Bit().toHex(' '));Note: if your text only contains ASCII characters, you can replace
toLocal8Bit()withtoLatin1(). If not, you should also check iftoUtf8()might be the better solution, but keep in mind that one character inlineEdit_1might result in several characters inlineEdit_2then.Regards
-
Hi all.
I want to display the string entered in lineEdit_1 in hexadecimal format in LineEdit_2.
For example, if I enter 12AB, yI want to display 31 32 41 42.What should I do?
Thank you.
Hi @taku-s,
just to add an example to @ChrisW67's good hints:
lineEdit_2->setText(lineEdit1->text().toLocal8Bit().toHex(' '));Note: if your text only contains ASCII characters, you can replace
toLocal8Bit()withtoLatin1(). If not, you should also check iftoUtf8()might be the better solution, but keep in mind that one character inlineEdit_1might result in several characters inlineEdit_2then.Regards
-
@taku-s said in Display hexdecima format:
I was able to solve
great, so please don't forget to mark your post as solved!