Skip to content
  • 0 Votes
    3 Posts
    916 Views
    I

    try:

    inline QDebug operator<<(QDebug &stream, const amazing &flag) { if (!flag) { return stream << testX(0x00); } amazing l_copy = flag; testX l_bit = testX(0x01); stream.noquote().nospace() << "("; forever { if (l_copy.testFlag(l_bit)) { stream.noquote().nospace() << l_bit; l_copy.setFlag(l_bit, false); if (!l_copy) break; stream.noquote().nospace() << "|"; } l_bit = testX(qint32(l_bit) << 1); } stream.noquote().nospace() << ")"; return stream; }
  • 0 Votes
    6 Posts
    4k Views
    jsulmJ

    You don't have to mix anything.
    What you use in your enum are hexadecimal values not binary.
    That means (left side hex, right side binary): 0x0 == 0, 0x1 == 1, 0x10 == 10000, 0x100 == 100000000!
    I guess what you actually want is what Chris Kawa said: 0x01 == 1, 0x02 == 10, 0x04 == 100, 0x08 == 1000, 0x10 == 10000