本文整理匯總了Python中qwt.qt.QtGui.QPainter.drawRects方法的典型用法代碼示例。如果您正苦於以下問題:Python QPainter.drawRects方法的具體用法?Python QPainter.drawRects怎麽用?Python QPainter.drawRects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qwt.qt.QtGui.QPainter
的用法示例。
在下文中一共展示了QPainter.drawRects方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: qwtDrawBackground
# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import drawRects [as 別名]
def qwtDrawBackground(painter, canvas):
painter.save()
borderClip = canvas.borderPath(canvas.rect())
if not borderClip.isEmpty():
painter.setClipPath(borderClip, Qt.IntersectClip)
brush = canvas.palette().brush(canvas.backgroundRole())
if brush.style() == Qt.TexturePattern:
pm = QPixmap(canvas.size())
QwtPainter.fillPixmap(canvas, pm)
painter.drawPixmap(0, 0, pm)
elif brush.gradient():
rects = []
if brush.gradient().coordinateMode() == QGradient.ObjectBoundingMode:
rects += [canvas.rect()]
else:
rects += [painter.clipRegion().rects()]
useRaster = False
if painter.paintEngine().type() == QPaintEngine.X11:
useRaster = True
if useRaster:
format_ = QImage.Format_RGB32
stops = brush.gradient().stops()
for stop in stops:
if stop.second.alpha() != 255:
format_ = QImage.Format_ARGB32
break
image = QImage(canvas.size(), format_)
p = QPainter(image)
p.setPen(Qt.NoPen)
p.setBrush(brush)
p.drawRects(_rects_conv_PyQt5(rects))
p.end()
painter.drawImage(0, 0, image)
else:
painter.setPen(Qt.NoPen)
painter.setBrush(brush)
painter.drawRects(_rects_conv_PyQt5(rects))
else:
painter.setPen(Qt.NoPen)
painter.setBrush(brush)
painter.drawRects(_rects_conv_PyQt5(painter.clipRegion().rects()))
painter.restore()