Saturday, November 13, 2010

[Qt] Kinetic Scrolling: Ariya's Example Arabic Wrapper

I've been looking for a way to implement kinetic scrolling. And I found it here , it was a great example for kinetic scrolling but neither commented nor ready to use in other projects.



So, I worked on it, put comments on some important lines of code, added some options, and wrapped it in an easy-to-use class.

This class can be used in the design like any widget you may have used; like QListWidget for example.

Here are the features of this class:
- Right alignment and Arabic text support.
- Icon/Iconless view.
- The choice of background/selection colors.
- Emits a signal if an item is selected twice (better than double clicking).


Here are the emportant methods and signals you'll need

[FlickableList]
public:
    FlickableList(bool withIcons = false, QWidget *parent = 0);

    void addItem(QString itemString);
    void addItem(QString itemString, QPixmap icon);

    void setBackgroundColor(QColor backgroundColor);
    void setSelectedItemColor(QColor selectedItemColor);

signals:
    void itemSelected(int row);

I uploaded an example with the class. It is a very basic example that shows some lines of "أوبونتو" and a message appears if an item is selected twice indicating the row number. I tested it on Desktop/Simulator/S60 Device.



All you need to use this class is the folder called "FlickableList".
(Download Full Example & Class)


References:
Qt Labs - Kinetic scrolling on any widgets [Posted by Ariya Hidayat]


Creative Commons License
Blog Example by Mahmoud Adly Ezzat is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

2 comments: