Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ListView of qml doesn't support my NumberAnimation!!!
Forum Updated to NodeBB v4.3 + New Features

ListView of qml doesn't support my NumberAnimation!!!

Scheduled Pinned Locked Moved General and Desktop
qmllistviewanimation
2 Posts 1 Posters 1.2k 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.
  • D Offline
    D Offline
    DidaHarp
    wrote on last edited by DidaHarp
    #1

    I want to locate the "currentItem" of the "listview" at the center of "view",so i use ListView's method "positionViewAtIndex()".And i also want the view change its "contentY" with an animation,but,the animation doesn't work!!!
    Can anybody tell me how to fix it?
    Here is my qml code:

    import QtQuick 2.4

    Item{
    width: 250;height:300
    ListView{
    id:lv
    anchors.fill: parent
    anchors.margins: 3
    spacing: 4
    clip: true
    delegate: Rectangle{
    width: parent.width
    height: 30
    color:(index % 2 == 0)?"gray":"lightgray"
    Text{
    anchors.centerIn: parent
    text:index+1
    color: parent.ListView.isCurrentItem?"blue":"black"
    }
    MouseArea{
    anchors.fill: parent
    onClicked: {
    lv.currentIndex=index; // to change the currentIndex,so that change the currentItem
    lv.positionViewAtIndex(index,ListView.Center); // to locate the currentItem at the center of the view
    }
    }
    }
    model:40

        Behavior on contentY {
            NumberAnimation{duration: 300} // I want to use animation to make it more beautiful
        }
    }
    

    }

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DidaHarp
      wrote on last edited by
      #2

      Anyone help?

      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