Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to scroll flickable smooth from code

$
0
0
I working in QtQuick 1.1 and I have a textbox with a lot of text inside a flickable. I also have a button. When I press the button I want to scroll the content. I have solved that by changing contentY position in the flickable. That works but is a bit “chunky”. Is there some easy way to do this smoother? My experimental code: import QtQuick 1.1   Rectangle {     id: rectangle2     width: 360     height: 160       MouseArea {         x: 102         width: 60         height: 50         anchors.left: parent.left         anchors.leftMargin: 236         anchors.top: parent.top         anchors.topMargin: 44         onClicked:         {             flickable1.contentY += flickable1.height * 0.8;               if(flickable1.contentY > flickable1.contentHeight - flickable1.height )                 flickable1.contentY = flickable1.contentHeight - flickable1.height;         }           Rectangle {             id: rectangle1             color: "#d30303"             anchors.fill: parent               Text {                 id: text1                 color: "#ffffff"                 text: qsTr("Scroll")                 anchors.horizontalCenter: parent.horizontalCenter                 anchors.verticalCenter: parent.verticalCenter                 verticalAlignment: Text.AlignVCenter                 horizontalAlignment: Text.AlignHCenter                 font.pixelSize: 12             }         }     }       Flickable {         id: flickable1         x: 0         y: 0         width: 123         height: 136         flickableDirection: Flickable.VerticalFlick         clip: true         contentWidth: text2.width         contentHeight: text2.height             Text {             id: text2             text: qsTr("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eu mauris a quam rhoncus tincidunt sed sed massa. Fusce tristique gravida justo mattis accumsan. Mauris ultrices ante ante. Sed venenatis feugiat velit ut commodo. Duis iaculis aliquam nibh vitae mollis. Donec tempus odio quis orci pulvinar accumsan. Integer tempor metus ac magna tempor ultricies. Fusce malesuada erat a ullamcorper scelerisque. Praesent elit lorem, tempus non aliquam laoreet, scelerisque ut nisi. Duis elit ante, imperdiet lobortis vulputate nec, iaculis vel nunc. Suspendisse potenti. Sed pharetra odio ut mauris iaculis eleifend")             anchors.fill: parent             width: 123             height: 500               wrapMode: Text.WordWrap             font.pixelSize: 12         }     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles