PyQt5基础学习-QBrush(进行填充操作) 1.qb.setBrush(设置填充样式)

下面介绍了多种填充样式的图像

"""
用画刷填充图像区域
"""
import sys, math
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class FillRect(QWidget):
    def __init__(self):
        super(FillRect, self).__init__()
        self.resize(600, 600)
        self.setWindowTitle("用画刷填充区域")

    def paintEvent(self, e):
        qp = QPainter()
        qp.begin(self)
        brush = QBrush(Qt.SolidPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 15, 90, 60)

        brush = QBrush(Qt.Dense1Pattern)
        qp.setBrush(brush)
        qp.drawRect(130, 15, 90, 60)

        brush = QBrush(Qt.Dense2Pattern)
        qp.setBrush(brush)
        qp.drawRect(250, 15, 90, 60)

        brush = QBrush(Qt.Dense3Pattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)

        brush = QBrush(Qt.HorPattern)
        qp.setBrush(brush)
        qp.drawRect(10, 105, 90, 60)


if __name__ == "__main__":
    app = QApplication(sys.argv)

    main = FillRect()
    main.show()

    sys.exit(app.exec_())

PyQt5基础学习-QBrush(进行填充操作) 1.qb.setBrush(设置填充样式)

 

上一篇:PyQt5基础学习-QDateTimeEdit(时间编辑器) 2.QDateTime().currentDateTime(获得当前的时间) 3.QDate.currentData(获得当前时间) 4.


下一篇:7-5 前后分离(同源策略、修改host、跨域)