📅  最后修改于: 2020-11-08 08:12:58             🧑  作者: Mango
PyQt中的所有QWidget类都是QPaintDevice类的子类。 QPaintDevice是可以使用QPainter绘制的二维空间的抽象。油漆设备的尺寸以像素为单位,从左上角开始。
QPainter类在小部件和其他可绘制设备(例如打印机)上执行低级绘制。通常,它在小部件的绘画事件中使用。每当微件外观更新时,都会发生QPaintEvent 。
绘画者通过调用begin()方法来激活,而end()方法则将其禁用。在两者之间,通过下表中列出的合适方法绘制所需的图案。
Sr.No. | Methods & Description |
---|---|
1 |
begin() Starts painting on the target device |
2 |
drawArc() Draws an arc between the starting and the end angle |
3 |
drawEllipse() Draws an ellipse inside a rectangle |
4 |
drawLine() Draws a line with endpoint coordinates specified |
5 |
drawPixmap() Extracts pixmap from the image file and displays it at the specified position |
6 |
drwaPolygon() Draws a polygon using an array of coordinates |
7 |
drawRect() Draws a rectangle starting at the top-left coordinate with the given width and height |
8 |
drawText() Displays the text at given coordinates |
9 |
fillRect() Fills the rectangle with the QColor parameter |
10 |
setBrush() Sets a brush style for painting |
11 |
setPen() Sets the color, size and style of pen to be used for drawing |