PyQt5 绘制多边形

from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
from PyQt5.QtGui import QBrush, QPen,QPainter, QPolygon
from PyQt5.QtCore import QPoint, Qt


class Window(QMainWindow):
    def __init__(self):
        super().__init__()

        self.title = "PyQt5 Drawing Polygon"
        self.InitWindow()

    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon("icon.png"))
        self.setWindowTitle(self.title)
        self.show()
        self.resize(1000,1000)


    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setPen(QPen(Qt.red, 2, Qt.SolidLine))

        # '601,164,396,899,601', '315,358,812,782,315'

        points = QPolygon([
            QPoint(601,315),
            QPoint(164,358),
            QPoint(396,812),
            QPoint(899,782),
            QPoint(601,315)
        ])

        painter.drawPolygon(points)



App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
上一篇:名悦集团:聚焦315,未被点名的汽车行业问题不容忽视


下一篇:315. 计算右侧小于当前元素的个数(逆序数)-归并排序-困难