I have a QString of 1500 QChar which I want to convert to an array of uint32_t. I am reading each element in for loop and trying to save each QChar of QString to uint32_t array. I can convert it to its equivalent representation (e.g. 1 -> 49) through data[i].unicode() but I want the same string in an uint32_t array form for further processing.
QString data = {1,'A','C',9,8,.....};
uint32_t Test[data.length()] = {0};
for (uint32_t i =0; i<data.length(); i++) {
Test[i] = data[i]; // here i need QChar to uint32_t conversion
}
Any solutions?
Taking into account that each
QCharholds only 16 bits and consist of two parts: cell and row, you can even pack twoQChars into a singleuint32_tnumber. I would do it in the following way:However if you still need to have a single integer number per
QCharyou can write similar loop without compression like: