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. Visible items of QML ListView
Qt 6.11 is out! See what's new in the release blog

Visible items of QML ListView

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

    Hi! I'm trying to get all visible items (indexes) of QML ListView, but i'm not shure how to realize this functionality. Maybe is some working approach exists? Thank you in advance.

    1 Reply Last reply
    1
    • F Offline
      F Offline
      FOXLISIN
      wrote on last edited by FOXLISIN
      #2

      Guys, what do you think about method like that?

      function populateVisibleItems() {
              var aStartPos = chatView.contentY;
              var aFinishPos = aStartPos + chatView.height;
              var aStep = 15;
      
              var aCurrentItem, aPreviousItem;
      
              for( var aCurrPos = aStartPos; aCurrPos <= aFinishPos; aCurrPos += aStep ) {
                  aCurrentItem = chatView.itemAt( 0, aCurrPos );
                  if( aCurrentItem && aCurrentItem.objectName === "message_item" && aPreviousItem !== aCurrentItem ) {
                      console.log( aCurrentItem.text + " is visible" );
                      // do some stuff (push into array, etc..)
                  }
                  aPreviousItem = aCurrentItem;
              }
          }
      
      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