This must be an easy one, but for some reason I can’t animate my Widget.
So a snippet of my widget code is:
class RoundedBox : public QGraphicsWidget
{
Q_PROPERTY( QPointF pos READ pos WRITE setPos )
public:
RoundedBox(QGraphicsWidget *parent = 0);
QPointF pos() const{ return QGraphicsObject::pos(); } // don't really need these - just for debug
void setPos( QPointF& pos ) { QGraphicsObject::setPos( pos ); }
...
};
And in my main window
I have:
void MainWindow::animate()
{
QPropertyAnimation animation(_rounded_box, "pos"); // just change position
animation.setDuration(10000);
animation.setStartValue(QPointF(0, 0));
animation.setEndValue(QPointF(100, 30));
animation.start();
}
Now the RoundedBox widget has been added to the scene, and is visible, but does not move when ‘animate’ is called.
Am I doing something rather silly here???
↧