Python PySide6
About Lesson

In this lesson we want to learn about Python PySide6 Add Effects to Graphics, As for the different types of graphics in PySide6, there are several classes that can be used to display and manipulate graphics, including:

QGraphicsScene: Container for graphics items such as QGraphicsPixmapItem or QGraphicsRectItem.
QGraphicsView: Widget that displays QGraphicsScene.
QGraphicsItem: Base class for all graphics items in QGraphicsScene. this class provides methods for setting and getting properties of a graphics item such as its position, size and appearance.
QGraphicsPixmapItem: Graphics item that displays pixmap such as an image.
QGraphicsRectItem: Graphics item that displays rectangle.
QGraphicsEllipseItem: Graphics item that displays an ellipse.
QGraphicsPathItem: Graphics item that displays QPainterPath.
QGraphicsTextItem: Graphics item that displays text.

 

 

This is an example of how to add effects to graphics using PySide6 in Python

In this example we have defined class called MyGraphicsView that inherits from QGraphicsView. In the constructor we have created new QGraphicsScene and set it as the scene for the view using setScene(). We have also created QGraphicsPixmapItem with an image and add it to the scene.

Next we create several QGraphicsEffect objects including QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsDropShadowEffect and QGraphicsOpacityEffect. these effects are stored as instance variables of the MyGraphicsView class.

Finally, we apply the effects to the QGraphicsPixmapItem using the setGraphicsEffect() method, and then we show the view and start the event loop using QApplication.exec().

 

 

Run the complete code and this will be the result.

Python PySide6 Add Effects to Graphics
Python PySide6 Add Effects to Graphics