开发者

QScrollArea - how to enable touch interactions to scroll to next item?

I'm using the Nokia Qt SDK and designed a small banner carousel in the top area. It looks like this:

QScrollArea - how to enable touch interactions to scroll to next item?

The hierarchy looks like:

QScrollArea - how to enable touch interactions to scroll to next item?

After installing this in the emulator, I try to make it scrollable (flinging). It's a simple task I would guess (like ScrollView in Android, or UIScrollView in iOS), but so far no joy. All links in the internet point me of custom scroll implementations etc etc. which I don't want to do nor expect to do as Qt should be a higher level framework? What is the state of the art here? ;-)

Question in short: How can I make this QScrollArea respond to tou开发者_开发技巧ch (fling, scroll, drag etc) events and reveal the other widgets in the queue? I'm not expecting it to be able to "snap" into a child widget (which is another requirement later ;)).


Take a look at Flickable (at http://blog.qt.io/blog/2009/07/19/kinetic-scrolling-on-any-widgets/) and FlickCharm (linked to from that first address ) either to have an idea on how to implement it on your own or use it as is.

Note that it might not be necessary if your target is Maemo, as its Qt port handles it.


Have you tried enabling gestures? I haven't used the gesture support yet, but it looks like it's as easy as

scrollEvents->grabGesture(Qt::SwipeGesture);
// or...
scrollEvents->grabGesture(Qt::PanGesture);

I don't know if QScrollArea already handles gestures, so if that doesn't work, you may need to sub-class QScrollArea and override the event method to handle gesture events, as described in the Gestures Programming Guide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜