Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to convert a qstring to hexadecimal
I am developing an interface where it is necessary to add a value in hexadecimal by means of a QLineEdit, I already have that part including the saving of the data, but I do it in String, I want to know how to save it in herxadecimal, preserving the format, for example, if I write in the QLineEdit: A2 I want to save it in a variable in that same format but in hexadecimal. I don't know if I'm clear, if someone understands what I want to do, can they help me please
Somthing like this.
This is a QLineEdit
I want sonthig like this![alt text] (image url)
Hex is a representation and not a basic true value so you cant really save it a variable as hex.
but you can convert a string between hex and decimal like this
QString str = "FF"; bool ok; int hex = str.toInt(&ok, 16); int dec = str.toInt(&ok, 10);
@mrjj Hi thanks
Coul you help me, i want to print this value on SerialPort but need to a on hex, how can i do it??
You can use a Qbytearray and send that
QByteArray array = QByteArray::fromHex( ui->xtxtAdress->text());
Thanks very much!
It helped me a lot.