Usage of abstract base class registered in QML

  • I've have a Q_OBJECT derived C++ base class, which is registered with QML using qmlRegisterType. This registered type is a property of a QML item, which defaults to null, like so:

    Item {
        id: root
        property QtBaseClass implementation: null

    In turn, there are many QML Items that contain this QML item. Each of them sets the propertyimplementation to an instance of a class derived from QtBaseClass.

    QtBaseClass itself has no useful function definitions, so I'd like to make it abstract. However, if I make it abstract and register it with qmlRegisterInterface or qmlRegisterUncreatableType, I can't use it as a QML property in this way, even if it is set to null.

    What is the intended method to accomplish what I'm doing?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.