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. How to correctly subscribe to changes in QQuickItem::childItems?
Forum Update on Monday, May 27th 2025

How to correctly subscribe to changes in QQuickItem::childItems?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
positioningchilditemschildrenlayoutitemchanged
2 Posts 1 Posters 868 Views
  • 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.
  • D Offline
    D Offline
    diredko
    wrote on last edited by
    #1

    Hi everyone :)
    I'm trying to implement custom positioner (i.e. like QML Row or Column) in C++ (inherited from QQuickItem) which would place children items in a honeycomb pattern. I want then expose it to QML and use it somewhat like this:

    HoneycombLayout {
        Repeater {
            model: someModel
            delegate: Cell {objectName: "#cell" + index}
       }
    
    }
    

    So far I'm stuck with getting notified when the order of children items of HoneycombLayout changes. I tried to catch children updates using childrenChanged signal and by overriding itemChange method but in both cases last I update I receive happens when childItems list has first item (item which is supposed to be first) at the end of the list.
    The ordering is getting fixed at some point (I checked this by repeatedly printing objectNames of items in childItems list in timer) but my handlers are not called when this happens and thus positioning is not updated.

    NOTE: I looked through implementation of standard QML positioners but they all seem to rely on private Qt which I would prefer not to use unless there is no other option.

    I would greatly appreciate any suggestions :)

    1 Reply Last reply
    0
    • D Offline
      D Offline
      diredko
      wrote on last edited by diredko
      #2

      After looking through implementation of Qt positioners (qquickpositioners.* in qtdeclarative) I have found that the positioning itself is done in updatePolish method while in itemChange and onCompleted methods positioning is schedule and polish is called.
      At this point I don't completely understand how it works, but it resolved my problem and I didn't have to resort to using qt private modules.

      1 Reply Last reply
      2

      • Login

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