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. QML ListView: error when change width of delegate

QML ListView: error when change width of delegate

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 488 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.
  • J Offline
    J Offline
    Jane Sully
    wrote on 25 Jan 2020, 12:20 last edited by Jane Sully
    #1

    Hi all,
    I want to create a list of item and the current item is bigger than others but i have an issue.
    When I flick the list so the first item is hidden and click on other item to change current index of listview, the contentX of listview is wrong. This only occur when the current index is 0
    More detail of what I do to test:

    • Current index is 0
    • Flick to the end of list and click on an item to change current index
    • Flick back to the begin and console.log(listView.contentX) => output 40 when it's suppose to output 0

    Anyone know how to fix this? I need to use contentX for another purpose.
    Here's my code:

    ListView{
            id:listView
            width: 1000; height:700
            orientation: ListView.Horizontal
            cacheBuffer: 20000
            spacing: 10
            model:15
            delegate: Rectangle{
                id:baseDele
                width: index == listView.currentIndex ? 120 : 100
                height: 500
                border.width: 1
                Text {
                    anchors.centerIn: parent
                    text:index
                }
                MouseArea{
                    anchors.fill: parent
                    onPressed: listView.currentIndex = index
                    onReleased: console.log(listView.contentX)
                    
                }
            }
        }
    
    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrecKo
      Qt Champions 2018
      wrote on 25 Jan 2020, 18:52 last edited by
      #2

      You need to use originX too.

      listView.contentX + listView.originX should be 0.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jane Sully
        wrote on 25 Jan 2020, 19:10 last edited by
        #3

        I try what you suggest but originX and contentX is the same

        1 Reply Last reply
        0

        1/3

        25 Jan 2020, 12:20

        • Login

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