[Qt-interest] Scrolling QScrollArea with mouse near borders?

David Greaves david at dgreaves.com
Mon Mar 30 13:55:13 CEST 2009


>>> Hi all,
>>>
>>> I have a question concerning QScrollArea:
>>> I want the scroll area to scroll automatically into the corresponding
>>> direction if I move the mouse cursor to the border of the scroll area.
>>> Does anyone know how to achieve this?

Just yesterday I posted this to the maemo-qt list (touchscreen tablet):

For those who are interested I've been working on fingerscrolling for Qt4.5

  http://www.youtube.com/watch?v=4TxAIScXQvk​

The only code change to an existing class is the following addition to the
initialiser of the QAbstractScrollArea class.

+#ifdef Q_WS_HILDON
+       new QAbstractScrollAreaPrivateScroller(this);
+#endif

(though I've implemented the class and definitions in qabstractscrollbar.*)

All the rest is done in QAbstractScrollAreaPrivateScroller, a monitor class
which filters events and, if scrolling doesn't happen, replays them.

This implements the finger scrolling, kinetics and should handle scrollbars
which have had the range set on them.

anyhow, Ariya posted this too:
  http://labs.trolltech.com/blogs/2008/11/15/flick-list-or-kinetic-scrolling/

It's not trivial to do generically but it seems possible.

(Nb this doesn't solve your problem directly but the solution approach would
probably work for you)

GPL source for my version:
https://garage.maemo.org/plugins/scmsvn/viewcvs.php?view=rev&root=qt4&revision=458

David

-- 
"Don't worry, you'll be fine; I saw it work in a cartoon once..."



More information about the Qt-interest-old mailing list