Using QML_VALUE_TYPE
-
Does anyone know a working example of defining a QML value type in C++ and actually using it in QML?
The Qt docs only show the C++ part, and none of the Qt Examples (at least in 6.5.2) covers this topic.Long story short, I have something like this:
namespace MyNamespace { class TestQmlValueType { Q_GADGET QML_VALUE_TYPE(ct_TestQmlValueType) public: int m_Something; }; } // namespace MyNamespace
This the header is added to a QML module via qt_add_qml_module (SOURCES parameter). The registration for that module is generated as expected (strangely, no mention of my value type, but maybe this is as it should be)
In a different QML module, I want to use the value type, import the QML module and...can't find it.
import MyPrefix.MyModule Rectangle { id: testRect proprerty ct_TestQmlValueType myPropOfCustomValueType // Unknown type }