Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12
-
None
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
Issue Links
- relates to
-
QTBUG-134106 As a user of Qt, I would like QMetaEnum's API to be more friendly towards QFlags and scoped enums
-
- Open
-