If I wanted to, using Qt, simply have some circles move around in a white bo开发者_如何学Gox, or a graphic, what would be the best method of this?
Would I need to draw white/the graphic behind where the circle moved from every time? Is there a simple way of accomplishing this in Qt?
- Create QGraphicsView object to your widget and added a QGraphicsScene to view.
- Add a QGraphicsEllipseItem to scene
- Use QPropertyAnimation to change the "pos" property of the ellipse item.
If you need more advanced features, you can build your own animation class on QPropertyAnimation.
enjoy it:)
Update: You can read Qt's Next Generation UI for more information.
Subclass a QWidget. Start a timerEvent() to animate the positions of the circles, then call update() at the end to schedule a repaint of the widget. Override the widget's paintEvent() - in there you draw your background and circles, using a QPainter object. The Qt Assistant has examples of how to use QPainter.
Qt also has a new animation framework that may facilitate something like this, but I have not looked into it.
精彩评论