Does this work?

Qt Code:
  1. #include <QtGui>
  2. #include <QPropertyAnimation>
  3.  
  4. class RectItem : public QObject, public QGraphicsRectItem {
  5. Q_OBJECT
  6. Q_PROPERTY(QPointF pos READ pos WRITE setPos)
  7. public:
  8. RectItem(const QRectF &rect, const QPen &pen, const QBrush &brush) : QObject(), QGraphicsRectItem(rect){
  9. setPen(pen);
  10. setBrush(brush);
  11. }
  12. };
  13.  
  14. #include "main.moc"
  15.  
  16. int main(int argc, char **argv){
  17. QApplication app(argc, argv);
  18. view.setAttribute(Qt::WA_TranslucentBackground);
  19. view.viewport()->setAttribute(Qt::WA_TranslucentBackground);
  20. QGraphicsScene scene(QRectF(0,0,1000,800));
  21. view.setScene(&scene);
  22. RectItem *rect = new RectItem(QRectF(0,0,200,100), QPen(Qt::red), Qt::blue);
  23. scene.addItem(rect);
  24. QPropertyAnimation *anim = new QPropertyAnimation(rect, "pos");
  25. anim->setDuration(10000);
  26. anim->setStartValue(scene.sceneRect().topLeft());
  27. anim->setEndValue(scene.sceneRect().bottomRight());
  28. anim->start();
  29. view.show();
  30. return app.exec();
  31. }
To copy to clipboard, switch view to plain text mode