Unable to write properties of Q_GADGET
-
Hi,
i've defined a QObject derived class and a Q_GADGET struct in C++ to use in QML:struct TypeName { Q_GADGET Q_PROPERTY(QString name MEMBER name) QString name; } Q_DECLARE_METATYPE(TypeName) class MyClass : public QObject { Q_OBJECT Q_PROPERTY(TypeName type READ type) public: MyClass() { qRegisterMetaType<TypeName>(); } Q_INVOKALBLE Type typeInvoked() const { return m_type; } TypeName type() const { return m_type; } private: TypeName m_type; }
If I call the property
MyClass.type
I'm not able to write the properties ofTypeName
. But if it is called by the invokable function I can:MyClass { id: myClass } var typeProperty= myClass.type typeProperty.name = "MyName" var typeInvoked = myClass.typeInvoked() typeInvoked.name = "MyName" console.log(typeProperty.name) // '' <- ? console.log(typeInvoked.name) // 'MyName'