Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to animate a circle moving around a screen in Qt?

If I wanted to, using Qt, simply have some circles move around in a white box, 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?

like image 760
adrien Avatar asked Jan 20 '26 18:01

adrien


1 Answers

  1. Create QGraphicsView object to your widget and added a QGraphicsScene to view.
  2. Add a QGraphicsEllipseItem to scene
  3. 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.

like image 105
Mason Zhang Avatar answered Jan 23 '26 08:01

Mason Zhang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!