Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Are BitField Unions discouraged in Qt?
Forum Updated to NodeBB v4.3 + New Features

Are BitField Unions discouraged in Qt?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    In the past outside of Qt I have done a lot of bit field work like this:

    @union GlyphBitFlags {
    uint32_t all;
    struct {
    uint32_t errors:1;
    uint32_t noarguments:1;
    uint32_t querymode:1;
    uint32_t editmode:1;
    uint32_t helpmode:1;
    uint32_t immediateArgValid:1;
    uint32_t bracketOpen:1;
    uint32_t bracketClose:1;
    };
    };@

    Qt seems tolerant of this. But its IDE isn't very helpful. For example:

    @GlyphBitFlags glyph;
    glyph.errors = false; @

    If I typed in creators IDE glyph., the pop up help doesn't display any suggestions for the bit field names. I wonder if this form of storing data is discouraged in Qt since it designed to be cross platform.

    If have looked at using QBitArray. Which is nice, except the bits are anonymous and I have to create a enum to get at them. This wouldn't be that big of a deal, except when I use Qt's debugger. The bits are even further removed because I see them presented in byte form. Wonder if there is anything else Qt offers to help create this kind of data structure?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      Qt does that using the "QFlags class":http://qt-project.org/doc/qt-5/QFlags.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved