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 access every delegate in a ListView from outside?
Forum Updated to NodeBB v4.3 + New Features

How to access every delegate in a ListView from outside?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 158 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.
  • Q Offline
    Q Offline
    QTLeearn
    wrote on last edited by QTLeearn
    #1

    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!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      1

      • Login

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