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. [SOLVED] QListView scrolling animation
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QListView scrolling animation

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 9.0k 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.
  • A Offline
    A Offline
    apap_
    wrote on 13 May 2011, 15:04 last edited by
    #1

    Hi,

    I want to have a QListView with scrolling animation when I select an item out of QListView visible range. It's done by default in QML with ListView, and I think it comes from Flickable inheritance.

    Where can I define the proper QPropertyAnimation ?
    Have I to reimplement QListView::scrollTo() or have I to manage animation in the QItemDelegate ?

    I don't understand when does the item container is painting because in my QItemDelegate::paint(..) reimplementation I never manage it. Can someone help me ?

    Regards

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 13 May 2011, 16:02 last edited by
      #2

      What you might be able to do, is something like this:

      • Get the position of the item to scroll to in your view (using QListView::visualRect())
      • Get a handle on the vertical scroll bar of the list view
      • Create a QPropertyAnimation to animate the value property of the vertical scroll bar to a value that will get your item into view

      Should be doable IMHO, but I have not tried it myself.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        srikanth_trulyit
        wrote on 13 May 2011, 16:16 last edited by
        #3

        You can use QPropertyAnimation in your QListView itself. It animates the property of a widget in this case it is the QListView::verticalScrollBar() "value" property. The start value would be the current scrollbar's value and the end value would be the QPoint at which the clicked index is present in the listview. There are many ways to get the clicked index's position in the view. To get a QML like feel in the animation provide enough animation duration and a eye caching easing curve - QEasingCurve (my fav is OutQuad though :) ) - build easingcurve example under Examples/Animation to see different easing curves.

        Though I have not verified, better to look at signal clicked(const QModelIndex) and find your way out to get the position of the supplied index. Once you get the target point simply animate it. See http://doc.trolltech.com/4.7/qpropertyanimation.html

        I don't see any point why animation should penetrate to delegate, it is something to do with QListView itself, so handle it there itself.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          apap_
          wrote on 16 May 2011, 06:49 last edited by
          #4

          It works nicely,
          thanks

          1 Reply Last reply
          0

          1/4

          13 May 2011, 15:04

          • Login

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