On 04/10/2024 15:32, Thiago Macieira wrote:
On Friday 4 October 2024 05:43:38 GMT-7 Phil Thompson via Development
wrote:
For dynamically created meta-objects...
- the results were dependent on the version of Qt
- QMetaProperty.metaType().isValid() always returned false
- QMetaProperty.isEnumType() returned true for v6.7.1 and false for
v6.8.0
But how was this constructed? Is it setting the QMP and QME's metatype
using
QMetaEnumBuilder::setMetaType and QMetaPropertyBuilder::setMetaType?
Uh...
there is no such function for QMPB.
I was surprised by the result of QMetaProperty.isEnumType() for a
moc-generated meta-object without Q_ENUM. The docs suggest this should
be true for all enums whether or not Q_ENUM is used.
No, it needs the bit set by moc, so Q_ENUM or Q_FLAG is required. The
doc may
be misleading then ("if the property's type is an enumeration value").
Why does QMetaProperty.metaType().isValid() always return true for
moc-generated meta-objects and false for dynamically created
meta-objects?
Because meta types for all properties are required since 6.0. There are
no
exceptions. Since 6.6, moc also generates the metatypes for all enums
too.
QMetaObjectBuilder always generates the latest revision of the meta
object, so
all features are available... but also all requirements are mandatory.
Meta
types for all properties, enums, methods , and for gadgets the gadget
itself
must be provided.
Is there any way to dynamically register an enum with the meta-type
system (so that QMetaEnum.metaType().isValid() returns true)?
Sure. And registration is automatic anyway.
All you should need to do is pass the necessary QMetaType
Understood - but there seems to be no obvious way to dynamically create
and register a valid QMetaType.
Phil
--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development