Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

2 bit alternative to QBitArray?



  • I am in need of a container similar to QBitArray that offers 4 possible values rather than 2, so I was wondering if Qt provides something out of the box?

    QByteArray is a complete overkill, I really prefer to keep it as small as possible.



  • You can store 4 symbols à 2 bit in a single byte (char) using some bitwise operator magic.

    Just write a wrapper around QByteArray...

    Either that are just use two QBitArrays instead of a single one ;-)



  • I was thinking about bit fields in a QVector with a few accessors, still wanted to check if there is something stock, perhaps not included in the documentation.


Log in to reply