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. ListView: Change anchor onCurrentIndexChanged
Qt 6.11 is out! See what's new in the release blog

ListView: Change anchor onCurrentIndexChanged

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 796 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.
  • diduD Offline
    diduD Offline
    didu
    wrote on last edited by
    #1

    hello,

    I wanna change the anchor of my ListView for a specifique Index value.
    But when "anchors.top" is change the currentIndex is "reset" to the last value.

    For exemple:

            onCurrentIndexChanged: {
                console.log("currentIndex : " + currentIndex);
                if (currentIndex == 0)
                    anchors.top = banner.bottom
                else
                    anchors.top = image.bottom
            }
    

    Runtime output:

    //current currentIndex = 2
    //set currentIndex = 0 from qml
    currentIndex :  0
    currentIndex :  2
    

    it look like anchor.top reset the currentIndex ?
    Is there any better way to change the anchor when index is changed ?

    Thanks in advance

    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