Animations with QPropertyAnimation
Learn to make animations using QPropertyAnimation with PyQt.
Creating the animations
In the subsequent application, you will discover how to use pyqtProperty
to add new properties to things, how to use the QPropertyAnimation
class to animate objects, and how to build a "Qt Graphics View" to display items and animations.
Firstly, we start by importing the required modules.
Press + to interact
import sysfrom PyQt6.QtWidgets import (QApplication, QGraphicsView, QGraphicsScene,QGraphicsPixmapItem)from PyQt6.QtCore import (QObject, QPointF, QRectF,QPropertyAnimation, pyqtProperty)from PyQt6.QtGui import QPixmap
We must add pyqtProperty
to the Objects
class to define a position property as QObject
lacks one. A pixmap can be added to the QGraphicsScene
using ...
Get hands-on with 1400+ tech skills courses.