我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtCore.Qt.SolidPattern()。
def paint( self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget): pen = QPen() pen.setWidth(3) painter.setRenderHint(QPainter.Antialiasing) pen.setColor(QColor(61, 61, 61, 255)) painter.setPen(pen) painter.setBrush(QBrush(QColor(61, 61, 61, 255), Qt.SolidPattern)) painter.drawRect( QRectF(-self.maxWidth / 2, -10, self.maxWidth, 20)) painter.setBrush(QBrush(QColor(240, 217, 108, 255), Qt.SolidPattern)) painter.drawRect( QRectF(-self.maxWidth / 2, -10, self.displayWidth, 20)) path = QPainterPath() path.addText(-self.maxWidth / 2, 35, QFont('monospace', 18, QFont.Bold), f'{self.name} Lv.{self.level} Exp. {self.actualExperience:{len(str(self.maxExperience))}}/{self.maxExperience}') # pen.setColor(Qt.white) pen.setWidth(2) painter.setPen(pen) painter.setBrush(QBrush(QColor(0, 0, 0, 61), Qt.SolidPattern)) painter.drawPath(path)
def paint( self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget): pen = QPen() pen.setWidth(1) painter.setRenderHint(QPainter.Antialiasing) pen.setColor(QColor(81, 81, 81, 255)) painter.setPen(pen) painter.setBrush(QBrush(QColor(81, 81, 81, 255), Qt.SolidPattern)) path = QPainterPath() path.addText( -self.width, self.height, QFont('monospace', 13, QFont.PreferNoHinting), self.text) painter.drawPath(path)
def paint( self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget): pen = QPen() pen.setWidth(1) painter.setRenderHint(QPainter.Antialiasing) pen.setColor(QColor(81, 81, 81, 255)) painter.setPen(pen) painter.setBrush(QBrush(QColor(81, 81, 81, 255), Qt.SolidPattern)) for i, score in enumerate(self.scores): path = QPainterPath() path.addText( -self.width, 14 + i * 16, QFont('monospace', 13, QFont.PreferNoHinting), f'{score.score:6}[{score.level:2}] {score.hero_name}') painter.drawPath(path)
def brush(self, color=Qt.white, style=Qt.SolidPattern): return QBrush(color, style)
def paint( self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget, ): painter.setRenderHint(QPainter.Antialiasing) painter.setPen(const.FramePen) painter.setBrush(const.HeroBarrelBrush) painter.drawPolygon(self.barrel) painter.setBrush(const.HeroBrush) painter.setBrush(QBrush(QColor(0, 178, 255, 255), Qt.SolidPattern)) painter.drawEllipse( -self.width / 2, -self.width / 2, self.width, self.width)