本文整理汇总了Python中PyQt5.QtCore.Qt.NoBrush方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.NoBrush方法的具体用法?Python Qt.NoBrush怎么用?Python Qt.NoBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.NoBrush方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def paint(self, painter, option, widget):
if self.scene().mode == 1:
self.setOpacity(1 if self.model_item.logging_active else 0.3)
painter.setOpacity(settings.SELECTION_OPACITY)
if self.hover_active or self.isSelected():
painter.setBrush(settings.SELECTION_COLOR)
elif not self.is_valid():
painter.setBrush(QColor(255, 0, 0, 150))
else:
painter.setBrush(QColor.fromRgb(204, 204, 204, 255))
height = self.number.boundingRect().height()
if self.model_item.type != ConditionType.ELSE:
height += self.desc.boundingRect().height()
painter.drawRect(QRectF(0, 0, self.boundingRect().width(), height))
painter.setBrush(Qt.NoBrush)
painter.drawRect(self.boundingRect())
if self.drag_over:
self.paint_drop_indicator(painter)
示例2: _createPointer
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def _createPointer(self):
# 绘制一个小圆环
self._imagePointer = QImage(12, 12, QImage.Format_ARGB32)
self._imagePointer.fill(Qt.transparent)
painter = QPainter()
painter.begin(self._imagePointer)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
painter.setPen(QPen(Qt.white, 2))
painter.setBrush(Qt.NoBrush)
path = QPainterPath()
path.addRoundedRect(0, 0, 12, 12, 6.0, 6.0)
painter.setClipPath(path)
painter.drawRoundedRect(0, 0, 12, 12, 6.0, 6.0)
painter.end()
示例3: _drawArc
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def _drawArc(self, painter: QPainter, radius: int):
# 绘制圆弧
painter.save()
painter.setBrush(Qt.NoBrush)
# 修改画笔
pen = painter.pen()
pen.setWidthF(self.BorderWidth)
pen.setCapStyle(Qt.RoundCap)
arcLength = 360.0 / (self.MaxValue - self.MinValue) * self.Value
rect = QRectF(-radius, -radius, radius * 2, radius * 2)
if not self.Clockwise:
# 逆时针
arcLength = -arcLength
# 绘制剩余进度圆弧
if self.ShowFreeArea:
acolor = self.BorderColor.toRgb()
acolor.setAlphaF(0.2)
pen.setColor(acolor)
painter.setPen(pen)
painter.drawArc(rect, (0 - arcLength) *
16, -(360 - arcLength) * 16)
# 绘制当前进度圆弧
pen.setColor(self.BorderColor)
painter.setPen(pen)
painter.drawArc(rect, 0, -arcLength * 16)
# 绘制进度圆弧前面的小圆
if self.ShowSmallCircle:
offset = radius - self.BorderWidth + 1
radius = self.BorderWidth / 2 - 1
painter.rotate(-90)
circleRect = QRectF(-radius, radius + offset,
radius * 2, radius * 2)
painter.rotate(arcLength)
painter.drawEllipse(circleRect)
painter.restore()
示例4: paintEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
# 背景白色
painter.fillRect(event.rect(), QBrush(Qt.white))
# 绘制边缘虚线框
painter.setPen(Qt.DashLine)
painter.setBrush(Qt.NoBrush)
painter.drawRect(self.rect())
# 随机画条线
for _ in range(3):
painter.setPen(QPen(QTCOLORLIST[qrand() % 5], 1, Qt.SolidLine))
painter.setBrush(Qt.NoBrush)
painter.drawLine(QPoint(0, qrand() % self.height()),
QPoint(self.width(), qrand() % self.height()))
painter.drawLine(QPoint(qrand() % self.width(), 0),
QPoint(qrand() % self.width(), self.height()))
# 绘制噪点
painter.setPen(Qt.DotLine)
painter.setBrush(Qt.NoBrush)
for _ in range(self.width()): # 绘制噪点
painter.drawPoint(QPointF(qrand() % self.width(), qrand() % self.height()))
# super(WidgetCode, self).paintEvent(event) # 绘制文字
# 绘制跳动文字
metrics = QFontMetrics(self.font())
x = (self.width() - metrics.width(self.text())) / 2
y = (self.height() + metrics.ascent() - metrics.descent()) / 2
for i, ch in enumerate(self.text()):
index = (self.step + i) % 16
painter.setPen(TCOLORLIST[qrand() % 6])
painter.drawText(x, y - ((SINETABLE[index] * metrics.height()) / 400), ch)
x += metrics.width(ch)
示例5: paint_drop_indicator
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def paint_drop_indicator(self, painter):
painter.setPen(QPen(Qt.darkRed, 2, Qt.SolidLine))
painter.setBrush(Qt.NoBrush)
rect = self.boundingRect()
if self.drop_indicator_position == QAbstractItemView.AboveItem:
painter.drawLine(QLineF(rect.topLeft(), rect.topRight()))
elif self.drop_indicator_position == QAbstractItemView.OnItem:
painter.drawRect(rect)
else:
painter.drawLine(QLineF(rect.bottomLeft(), rect.bottomRight()))
示例6: drawCircle
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def drawCircle(self, painter, circle):
# circle.radius *= circleExp
if circle.background:
circle.radius *= circleExp
else:
circle.radius /= circleExp
radius = circle.radius
r = radius * circleExp
# 边框颜色设置透明度
c = QColor(circle.borderColor)
c.setAlphaF(circle.opacity)
painter.save()
if circle.filled == 'full':
# 设置背景刷
painter.setBrush(c)
painter.setPen(Qt.NoPen)
else:
# 设置画笔
painter.setPen(
QPen(c, max(1, circleBorder * (radMin - circle.radius) / (radMin - radMax))))
# 画实心圆或者圆圈
painter.drawEllipse(circle.x - r, circle.y - r, 2 * r, 2 * r)
painter.restore()
if circle.filled == 'concentric':
r = radius / 2
# 画圆圈
painter.save()
painter.setBrush(Qt.NoBrush)
painter.setPen(
QPen(c, max(1, circleBorder * (radMin - circle.radius) / (radMin - radMax))))
painter.drawEllipse(circle.x - r, circle.y - r, 2 * r, 2 * r)
painter.restore()
circle.x += circle.speedx
circle.y += circle.speedy
if (circle.opacity < maxOpacity):
circle.opacity += 0.01
circle.ttl -= 1
示例7: drawWidget
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import NoBrush [as 别名]
def drawWidget(self, qp):
MAX_CAPACITY = 700
OVER_CAPACITY = 750
font = QFont('Serif', 7, QFont.Light)
qp.setFont(font)
size = self.size()
w = size.width()
h = size.height()
step = int(round(w / 10))
till = int(((w / OVER_CAPACITY) * self.value))
full = int(((w / OVER_CAPACITY) * MAX_CAPACITY))
if self.value >= MAX_CAPACITY:
qp.setPen(QColor(255, 255, 255))
qp.setBrush(QColor(255, 255, 184))
qp.drawRect(0, 0, full, h)
qp.setPen(QColor(255, 175, 175))
qp.setBrush(QColor(255, 175, 175))
qp.drawRect(full, 0, till-full, h)
else:
qp.setPen(QColor(255, 255, 255))
qp.setBrush(QColor(255, 255, 184))
qp.drawRect(0, 0, till, h)
pen = QPen(QColor(20, 20, 20), 1,
Qt.SolidLine)
qp.setPen(pen)
qp.setBrush(Qt.NoBrush)
qp.drawRect(0, 0, w-1, h-1)
j = 0
for i in range(step, 10*step, step):
qp.drawLine(i, 0, i, 5)
metrics = qp.fontMetrics()
fw = metrics.width(str(self.num[j]))
qp.drawText(i-fw/2, h/2, str(self.num[j]))
j = j + 1