Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Reorder Item childrens
Qt 6.11 is out! See what's new in the release blog

Reorder Item childrens

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FabriceS
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Can you show us some code?

      1 Reply Last reply
      0
      • F Offline
        F Offline
        FabriceS
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved