PDA

View Full Version : QByteArray can not support unsigned char?



olosie
4th March 2010, 11:51
I want read binary file and load data to unsigned char array. My code is:


QFile f("a.a");
f.open(QFile::ReadOnly);
QByteArray d = f.readAll();
f.close();

Functions from QFile and QByteArray support only signed char not unsigned char. I can not understand reason for using signed char because for me byte=unsigned char.
Is there any possibility to read unsigned char from file? Of course I can convert every signed char to unsigned char but mayby exsist easier way for this problem?

olosie
31st July 2010, 09:18
Nobody knows solution?

squidge
31st July 2010, 10:02
QByteArray doesn't specify either signed or unsigned, check the header file. Therefore you can define it as either signed or unsigned depending on your requirements.

This is not a Qt issue, it's covered in the introduction to GCC (http://www.network-theory.co.uk/gcc/intro/).