I wrote a C++ plugin that exposes a C++ "MyCppClass" for QML. The "Q_INVOKABLE" members work, but I cannot "see" any "Q_PROPERTY" values for the *same* instance.
Assume a trivial "MyCppClass": //----------- class MyCppClass : public QObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) public: MyCppClass(); virtual ~MyCppClass(); Q_INVOKABLE void myInvokeFunc(); int value(); void setValue(int i); signals: void valueChanged(int); private: int m_iValue; }; //----------- Example QML use: //----------- // FILE: MyQml.qml import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Window 2.0 import MyCppPlugin 1.0 Item { MyCppClass { //<==OK id: myClass //<==OK value: 42 //<==QML LOAD ERROR } Button { text: "Hello" onClicked: { myClass.myInvokeFunc() //<==OK } } //----------- What's going on: *- SUCCESS: C++ Plugin loads through QML "import" *- SUCCESS: Instantiating a C++ object in QML *- SUCCESS: Calling "Q_INVOKABLE" function from QML *- FAIL: Accessing any properties in QML from that *same* C++ object (QML fails to load, error: "Cannot assign to non-existent property "value"") .... assigning/binding fails to load the QML file, and "reading" any property results in "undefined") This doesn't make sense to me (Qt 5.1.1, Win7). The plugin loads, the C++ object is instantiated, the "Q_INVOKABLE" function works, but I apparently cannot "see" any "Q_PROPERTY" values. QUESTION: What are the possible scenarios where "Q_INVOKABLE" works on an instance, but "Q_PROPERTY" properties are still unavailable for that *same* instance? --charley
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest