All the QWidget classes in PyQt are sub classed from QPaintDevice class. A QPaintDevice is an abstraction of two dimensional space that can be drawn upon using a QPainter. Dimensions of paint device are measured in pixels starting from the top-left corner.
QPainter class performs low level painting on widgets and other paintable devices such as printer. Normally, it is used in widget’s paint event. The QPaintEvent occurs whenever the widget’s appearance is updated.
The painter is activated by calling the begin() method, while the end() method deactivates it. In between, the desired pattern is painted by suitable methods as listed in the following table.
|Sr.No.||Methods & Description|
Starts painting on the target device
Draws an arc between the starting and the end angle
Draws an ellipse inside a rectangle
Draws a line with endpoint coordinates specified
Extracts pixmap from the image file and displays it at the specified position
Draws a polygon using an array of coordinates
Draws a rectangle starting at the top-left coordinate with the given width and height
Displays the text at given coordinates
Fills the rectangle with the QColor parameter
Sets a brush style for painting
Sets the color, size and style of pen to be used for drawing