Important: Please read the Qt Code of Conduct -

emitting multiple signals at once from c++ to qml

  • Hello,
    I have a list of my onw QObjects in C++

    QList<QObject *>

    This list is exposed to QML by a wrapper class

     qmlRegisterSingletonType<ListManager> ("foo", 1, 0, "Lists",
                [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
            return new ListManager;

    In QML I iterate over that list to dynamically create a bunch of objects

    for(var i=0; i < objects.length; i++) {
       var myCppObject = objects[i];
       var object = Qt.createQmlObject('MyQMLObject {}', parent); = Qt.binding(function() {return; });

    As you can see I am using Qt.binding() to bind a property from the Cpp Object to the QML Object. This property is defined like this:

    // myobject.cpp
        Q_PROPERTY(int property READ property NOTIFY propertyChanged)
        void propertyChanged(int newProperty);

    Now when I change a bunch of objects in a loop in C++ I get the following behavior (in pseudo code):

    //in cpp
    emit propertyChanged(1); //for object 1
    emit propertyChanged(2); //for object 2
    emit propertyChanged(3); //for object 3
    // in qml
    onPropertyChanged 3 // for object 3
    onPropertyChanged 3 // for object 1
    onPropertyChanged 3 // for object 2

    What am I missing?
    Thank you,

  • This post is deleted!

Log in to reply