Important: Please read the Qt Code of Conduct -

How to access every delegate in a ListView from outside?

  • Hi, in my codes there is a ListView , I would like to access every item from the outside, and i want to check their properties, so I did something like this:

    function accessEveryDelegate()
            for(var i = 0; i < listViewId.count; i++)
                  listViewId.itemAt(0,i)   //not working?

    It seems listViewId.itemAt(0,i) always returns the first item... How should I properly manipulate the input parameters x y of itemAt(x, real y) ?
    Am I doing the correct thing? Are there other better approaches?
    Thank you in advance!

  • Moderators

    x and y are in pixels. So you will get the first item for the amount of pixels of your first delegate's width.

    It is not recommended to access delegates from outside. ListView can create, delete, swap the delegate instances at any time and it will not warn you about it. Your reference might get deleted while you are processing it.

    As for better: there is itemAtIndex() but my warnings still apply.

Log in to reply