Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
Description
Using custom namespaced types in signals, slots, invokables requires special care. From QTBUG-73761 :
This is a known limitation of the current QMetaObject/QMetaType system, which do lookup by name.
So the name (seen by moc) need to be be written the same in the Q_DECLARE_METATYPE, and in the Q_PROPERTY, and in the class definition.
In Qt, we usually therefore fully qualify all types in Q_INVOKABLE, slot, and Q_PROPERTY signatures, as well as in qmlRegisterTypeXXX calls. ANyhow, this is only documented for Q_DECLARE_METATYPE:
If MyStruct is in a namespace, the Q_DECLARE_METATYPE() macro has to be outside the namespace:
Such advice should be added to the documentation of Q_INVOKABLE, Q_PROPERTY ... too. An overview section about this might be added e.g. to https://doc.qt.io/qt-5/metaobjects.html .
Attachments
Issue Links
- resulted from
-
QTBUG-73761 A pointer to a QObject derived user type within a namespace cannot be used as the return type of a Q_INVOKABLE function unless the fully qualified type name is used.
- Closed