Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73387

Add support for QFlags in QMetaObject & QMetaType

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12
    • Core: Other
    • None
    • All

    Description

      QMetaType currently does not know about QFlags, i.e. none of the QMetaType::TypeFlags indicate it and MetaType::IsEnumeration is not set.

      The latter is a little inconsistent, because if the QFlags are declared with the Q_FLAG macro, you can perfectly well get the underlying QMetaEnum with QMetaEnum::fromType() and the flags are listed as enumerators in the QMetaObject of the containing type.

      My suggestion would be to either set QMetaType::IsEnumeration for QFlags or to introduce a QMetaType::IsFlags type flag.

      This bug has occured to us in QtWebChannel development when trying to marshall QFlags to integers and vice-versa. The current way of detecting QFlags is rather expensive by going through the enumerators of the containing QMetaObject by name.

      Then the next problem occurs: QMetaType should probably have converter functions for int -> QFlags and QFlags -> int, which it currently doesn't have.

      All in all this makes working with QMetaType pretty ugly as soon as QFlags types are involved.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            msarehn Arno Rehn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes