Making your thumbnails jump
Let's apply what we learned about the Qt Animation Framework to our project. Each time the user clicks on a filter thumbnail, we want to poke it. All modifications will be done on the FilterWidget
class. Let's start with FilterWidget.h
:
#include <QPropertyAnimation> class FilterWidget : public QWidget { Q_OBJECT public: explicit FilterWidget(Filter& filter, QWidget *parent = 0); ~FilterWidget(); ... private: void initAnimations(); void startSelectionAnimation(); private: ... QPropertyAnimation mSelectionAnimation; };
The first function, initAnimations()
, initializes the animations used by FilterWidget
. The second function, startSelectionAnimation()
, performs tasks required to start this animation correctly. As you can see, we are also declaring a QPropertyAnimation
class, as covered in the previous section.
We can now update FilterWidget.cpp
. Let's update the constructor:
FilterWidget::FilterWidget...