Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Reorder Item childrens



  • I am creating childs dynamically using createObject and to reorder them I use this code

    container.children = sorted_objects
    

    but QML warn TypeError: Cannot read property of null on each reference to parent.

    I know I can use a Repeater for this purpose but a Loader takes a Component not an object.



  • Hi! Can you show us some code?



  • Basically

    Main.qml

    Column {
        id: container
    }
    

    Component.qml

    Item {
         anchors.horizontalCenter: parent.horizontalCenter // Warn here
    }
    
    JS file
    

    var items = [];
    var obj = component.createObject(container, properties);
    items.push(obj);
    items.sort();
    container.children = items; // Warn


Log in to reply