QString inval = ui->inputLINE->text(); quint32 val = inval.toUInt(NULL, 16); QByteArray ba = inval.toLocal8Bit(); qDebug() << ba[0];
char * QByteArray::data ()Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the '\0' terminator.const char * QByteArray::constData () constReturns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\0'-terminated unless the QByteArray object was created from raw data. The pointer remains valid as long as the byte array isn't reallocated or destroyed.This function is mostly useful to pass a byte array to a function that accepts a const char *.Note: A QByteArray can store any byte values including '\0's, but most functions that take char * arguments assume that the data ends at the first '\0' they encounter.
QString dataString("10245634f"); QStringList list; int i = 0; QString tmpString; while(0 != (tmpString = dataString.mid(i, 2))) { // list.append(tmpString); i +=2; }
QByteArray out_val;foreach (QString str, list) { uint value = str.toUInt(NULL, 16); out_val = (quint8)value; }