Parameterizing a QML component with a registered C++ class having a QProperty

  • I have defined in Python (alternatively C++) a class A which has a notifiable Qt property B. I registered the class A with QML. I want to parameterize a QML Component with the property B of class A.

    This doesn't work, it quietly fails to emit a signal 'changed' from property B.


    @import MyComponent 1.0
    import A 1.0 // C++ class A is registered

    Item {
    model: A{}
    MyComponent.MyComponent{ componentModel: model.b } // specialize component with model: property b of instance of class A


    @MyComponent {
    property var componentModel
    onActivated { componentModel = 1 }

    This works: same as above except:

    @ MyComponent.MyComponent{ componentModel: model } // specialize with class A@


    @ onActivated { componentModel.b = 1 } // component accesses property b of instance of A@

    Why doesn't the first example work? That is, why can't I pass a QProperty to parameterize a component?

    There is a discussion here:, but I think that I have properly exposed (to QML engine) the class A and its property B.

Log in to reply

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