Unsolved C++ Inheritance and QML component reuse
-
Hi,
I have C++ class that is registered to QML:// baseclass.cpp BaseClass { virtual void doSomething(); }
qmlRegisterType<BaseClass >("Repository", 1, 0, "BaseClassItem");
and QML component that graphically represents that type:
// base.qml BaseClassItem { id: base // some graphics // and some functionality, e.g. on click do something MouseArea{ anchors.fill: parent onClicked: { base.doSomething(); } } }
What is the correct way to implement new QML component that reuses base.qml and inherits functionatity from BaseClass? Derived QML component should reuse graphics from base.qml and provide some additional content to it (e.g. draw a rectangle in the center of base.qml)
// derivedclass.cpp DerivedClass : public BaseClass { void DoSomething(); }
qmlRegisterType<DerivedClass >("Repository", 1, 0, "DerivedClassItem");
// derived.qml ???
-
Hi @MartinD,
Something like this:
https://forum.qt.io/topic/56491/has-a-relationship-in-qml/3