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. Flickable - Scroll smoothly programatically
QtWS25 Last Chance

Flickable - Scroll smoothly programatically

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
flickable scrol
4 Posts 3 Posters 4.6k 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.
  • L Offline
    L Offline
    lqsa
    wrote on 10 Jan 2016, 01:04 last edited by
    #1

    Hello,

    Imagine a Flickable item with 100 pixels height and 300 pixels contentHeight. If the user scrolls to down, the contentY property has 300. If the contentY is changed to 0, the Flickable item moves the content to the begin. But, how can I do a smooth scroll to up when the contentY is changed? The effect is like the user moves with its finger the content to the begin.

    Best regards.

    ? 1 Reply Last reply 10 Jan 2016, 13:21
    0
    • L lqsa
      10 Jan 2016, 01:04

      Hello,

      Imagine a Flickable item with 100 pixels height and 300 pixels contentHeight. If the user scrolls to down, the contentY property has 300. If the contentY is changed to 0, the Flickable item moves the content to the begin. But, how can I do a smooth scroll to up when the contentY is changed? The effect is like the user moves with its finger the content to the begin.

      Best regards.

      ? Offline
      ? Offline
      A Former User
      wrote on 10 Jan 2016, 13:21 last edited by
      #2

      @lqsa You can use the method flick to start an animated movement, see http://doc.qt.io/qt-5/qml-qtquick-flickable.html#flick-method

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lqsa
        wrote on 12 Jan 2016, 09:35 last edited by
        #3

        I've tested

        QMetaObject::invokeMethod(child, "flick", Q_ARG(qreal, 0.), Q_ARG(qreal, -200.)
        

        and

        QMetaObject::invokeMethod(child, "flick", Q_ARG(qreal, 0.), Q_ARG(qreal, 200.)
        

        but nothing happens, doesn't scroll.

        C 1 Reply Last reply 12 Jan 2016, 15:32
        0
        • L lqsa
          12 Jan 2016, 09:35

          I've tested

          QMetaObject::invokeMethod(child, "flick", Q_ARG(qreal, 0.), Q_ARG(qreal, -200.)
          

          and

          QMetaObject::invokeMethod(child, "flick", Q_ARG(qreal, 0.), Q_ARG(qreal, 200.)
          

          but nothing happens, doesn't scroll.

          C Offline
          C Offline
          Charby
          wrote on 12 Jan 2016, 15:32 last edited by
          #4

          @lqsa In think you could use a Behavior on ContentY.

          Would this give you want ?

          import QtQuick 2.0
          import QtQuick.Window 2.0
          
          Window{
              visible:true;
              Flickable {
                  width: 100; height: 150
                  contentWidth: 300; contentHeight: 300
          
          
                  Behavior on contentY{
                      NumberAnimation {
                          duration: 1000
                          easing.type: Easing.OutBounce
                      }
                  }
          
                  Timer{
                      running: true;
                      interval: 1500
                      repeat: true
                      onTriggered:{
                          if (parent.contentY==0) parent.contentY=300;
                          else parent.contentY=0;
                      }
                  }
          
                  Rectangle {
                      width: 300; height: 300
                      gradient: Gradient {
                          GradientStop { position: 0.0; color: "lightsteelblue" }
                          GradientStop { position: 1.0; color: "blue" }
                      }
                  }
              }
          }
          
          1 Reply Last reply
          2

          4/4

          12 Jan 2016, 15:32

          • Login

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