Hello people,
I'm looking to manipulate a vector of bits, but some basic types like QBitArray, QByteArray not allow me to conversion string and be shown on the label.
I also tried to use QVector.
What do you recommend?
Printable View
Hello people,
I'm looking to manipulate a vector of bits, but some basic types like QBitArray, QByteArray not allow me to conversion string and be shown on the label.
I also tried to use QVector.
What do you recommend?
Some inspiration:
http://developer.qt.nokia.com/wiki/WorkingWithRawData
You might like to reverse bit order.Code:
ba.setBit(5, true); ba.setBit(7, true); QString text; for (int i = 0; i < ba.size(); ++i) text += ba.testBit(i) ? "1": "0"; qDebug() << text;
If you are manipulating a small number of bits then direct use of an unsigned int is also a possibility.
Code:
unsigned int bitmap = 0; bitmap |= 1 << 5; bitmap |= 1 << 7;
Thanks guys.