These are my very first steps in Qt. I am trying to create a simple animation (under Ubuntu, Qt 4.8), and I don't think I am setting things up correctly.

I have a class MyWidget, inherited from QWidget:

Qt Code:
  1. class MyWidget : public QWidget
  2. {
  3. Q_OBJECT
  4. Q_PROPERTY(double rmin READ rmin WRITE setmin)
  5.  
  6. public:
  7. MyWidget();
  8. double rmin() const;
  9. void setmin(double m);
  10. ...
  11.  
  12. protected:
  13. void paintEvent(QPaintEvent *event);
  14. signals:
  15.  
  16. public slots:
  17. private:
  18. double p_rmin;
  19. ...
  20. };
To copy to clipboard, switch view to plain text mode 

The getter and setter functions for the property are
Qt Code:
  1. double MyWidget::rmin() const{
  2. return p_rmin;
  3. }
  4.  
  5. void MyWidget::setmin(double m){
  6. p_rmin=m;
  7. }
To copy to clipboard, switch view to plain text mode 

The function
Qt Code:
  1. void MyWidget::paintEvent(QPaintEvent *event)
To copy to clipboard, switch view to plain text mode 
uses the variable p_rmin to draw something (it access the variable only through the getter). Finally, my main() is:
Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4. MyWidget w;
  5. w.show();
  6.  
  7. QPropertyAnimation* animation = new QPropertyAnimation(&w, "rmin");
  8. animation->setDuration(5000);
  9.  
  10. animation->setStartValue(2.5);
  11. animation->setEndValue(3.3);
  12.  
  13. animation->start(QAbstractAnimation::DeleteWhenStopped);
  14. return a.exec();
  15. }
To copy to clipboard, switch view to plain text mode 

When I run this, I only see the static picture that was drawn for the starting value of p_rmin (which was also initialised by the constructor of MyWidget). But every time I resize the window, or switch between windows, and thereby force a redraw, I see a picture for a corresponding intermediate value. If I include a call to update() in the property setter, then the animation works. Surely, the animate object should be forcing a redraw if I had set up things correctly? Many thanks in advance!