本文整理汇总了Python中PySide.QtGui.QPainter.setRenderHint方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.setRenderHint方法的具体用法?Python QPainter.setRenderHint怎么用?Python QPainter.setRenderHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainter
的用法示例。
在下文中一共展示了QPainter.setRenderHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paint(self, canvas, is_secondary_color=False, additional_flag=False):
pen = QPen()
if is_secondary_color:
pen.setColor(self.data_singleton.secondary_color)
else:
pen.setColor(self.data_singleton.primary_color)
painter = QPainter(canvas.image)
painter.setRenderHint(QPainter.Antialiasing)
pen.setWidth(self.data_singleton.pen_size)
pen.setStyle(Qt.SolidLine)
pen.setCapStyle(Qt.RoundCap)
pen.setJoinStyle(Qt.RoundJoin)
painter.setPen(pen)
if is_secondary_color:
painter.setBrush(self.data_singleton.primary_color)
else:
painter.setBrush(self.data_singleton.secondary_color)
if self._start_point != self._end_point:
painter.drawRect(QRect(self._start_point, self._end_point))
painter.end()
canvas.edited = True
canvas.update()
示例2: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, painteevent):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
for obj in self.objects:
obj.paint(painter)
示例3: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, ev):
if self.isEnabled():
color = self.color
colorBorder = [0.4, 0.4, 0.4]
else:
color = [0.8, 0.8, 0.8]
colorBorder = [0.7, 0.7, 0.7]
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.setRenderHint(QPainter.HighQualityAntialiasing)
if self.isChecked():
pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
pen.setWidth(2.0)
else:
pen = QPen(QColor.fromRgbF(colorBorder[0], colorBorder[1], colorBorder[2]))
pen.setWidth(1.0)
size = self.size()
sizeCircle = 12.0
x = size.width() / 2.0 - (sizeCircle / 2.0)
y = size.height() / 2.0 - (sizeCircle / 2.0)
rect = QRectF(x, y, sizeCircle, sizeCircle)
painter.setPen(pen)
painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
painter.drawEllipse(rect)
示例4: render
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def render(self, fileName, width, height):
self.setViewportSize(QSize(width, height))
fileInfo = QFileInfo(fileName)
dir = QDir()
dir.mkpath(fileInfo.absolutePath())
viewportSize = self.viewportSize()
pageSize = self.mainFrame().contentsSize()
if pageSize.isEmpty():
return False
buffer = QImage(pageSize, QImage.Format_ARGB32)
buffer.fill(qRgba(255, 255, 255, 0))
p = QPainter(buffer)
p.setRenderHint( QPainter.Antialiasing, True)
p.setRenderHint( QPainter.TextAntialiasing, True)
p.setRenderHint( QPainter.SmoothPixmapTransform, True)
self.setViewportSize(pageSize)
self.mainFrame().render(p)
p.end()
self.setViewportSize(viewportSize)
return buffer.save(fileName)
示例5: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, pe):
# make an arrow polygon right in the middle
painter = QPainter(self)
painter.setPen(Qt.NoPen)
# draw the background transparent rect
painter.save()
painter.setOpacity(self.BACKGROUND_OPACITY)
# get the rectangle coordinates it should extend over the whole width with only a portion at the center
painter.setBrush(Qt.black)
empty_space_percent = 1 - self.BACKROUND_HEIGHT_PERCENT
rect_top = empty_space_percent / 2 * self.height()
rect_height = self.BACKROUND_HEIGHT_PERCENT * self.height()
painter.drawRect(0, rect_top, self.width(), rect_height)
painter.restore()
painter.setRenderHint(QPainter.Antialiasing)
pen = QPen()
pen.setWidth(self.ARROW_LINE_WIDTH)
pen.setCapStyle(Qt.RoundCap)
if self._mouse_inside:
pen.setColor(self._hover_color)
else:
pen.setColor(self._normal_color)
# get the arrow coords
painter.setPen(pen)
self_center = QPointF(self.width() / 2, self.height() / 2) # use this as the arrow tip for now
if self._direction == self.LEFT:
h_shift = self._arrow_width
elif self._direction == self.RIGHT:
h_shift = - self._arrow_width
v_shift = self._arrow_height / 2
top_point = self_center + QPointF(h_shift, - v_shift)
bottom_point = self_center + QPointF(h_shift, v_shift)
painter.drawLine(top_point, self_center)
painter.drawLine(self_center, bottom_point)
示例6: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, paintEvent):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.scale(self.scale, self.scale)
painter.drawRect(0, 0, 511, 511)
painter.drawImage(0, 0, self.image)
if self.freeze_image is not None and self.freeze_image is not self.image:
painter.setOpacity(0.3)
painter.drawImage(0, 0, self.freeze_image)
示例7: __init__
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def __init__(self, parent=None):
self.hamburger = QImage(128, 128, QImage.Format_ARGB32)
QPushButton.__init__(self, parent)
self.svgrenderer = QSvgRenderer("icons\\hamburger.svg")
paint = QPainter(self.hamburger)
paint.setRenderHint(QPainter.HighQualityAntialiasing)
paint.setRenderHint(QPainter.SmoothPixmapTransform)
self.svgrenderer.render(paint)
paint.end()
pixmap = QPixmap()
self.setIcon(QIcon(pixmap.fromImage(self.hamburger)))
self.setStyleSheet("QPushButton, QPushButton:pressed{background-color: rgba(0,0,0,0)} QPushButton:hover {background-color: rgba(255,255,255,100); border-radius: 32px} ")
示例8: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, ev):
size = self.size()
height = size.height() - 5
width = size.width() - 5
offset = 0.5
rect = QRectF(2.0 + offset, 2.0 + offset, width, height)
painter = QPainter(self)
painter.setPen(self._pen)
painter.setBrush(QColor(self._color[0], self._color[1], self._color[2]))
painter.setRenderHint(QPainter.Antialiasing)
painter.setRenderHint(QPainter.HighQualityAntialiasing)
painter.drawRoundedRect(rect, 4, 4)
示例9: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
for widget in self._widgets:
painter.translate(widget.x(),widget.y()) # move the painter to the widget's coordinates
painter.setClipRect(0,0,widget.width(),widget.height()) # restrict the painting area
widget._paint(painter) # paint the widget
painter.translate(-widget.x(),-widget.y()) # get the painter ready for the next widget
painter.setClipRect(self.rect()) # to be painted
painter.end()
示例10: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, event):
"""
Handles the ``paintEvent`` event for :class:`MdiArea`.
:param `event`: A `QPaintEvent`_ to be processed.
"""
vport = self.viewport()
rect = vport.rect()
painter = QPainter(vport)
painter.setRenderHint(painter.SmoothPixmapTransform)
# Always fill with a solid color first
if self.useColor:
# painter.fillRect(rect, self.colorBrush)
painter.fillRect(rect, self.bgColor)
else:
painter.fillRect(rect, self.background())
# Then overlay the texture
if self.useTexture:
# painter.fillRect(rect, self.backgroundBrush)
bgBrush = QBrush(self.bgTexture)
painter.fillRect(rect, bgBrush)
# Overlay the logo last
if self.useLogo:
if not len(self.subWindowList()): # Nothing is open.
cSizeW, cSizeH = rect.width(), rect.height()
bgLogoW, bgLogoH = self.bgLogo.width(), self.bgLogo.height()
if bgLogoW > cSizeW:
# Proportional Scaling an Image.
newHeight = bgLogoH * cSizeW // bgLogoW
scaledLogo = self.bgLogo.scaled(cSizeW, newHeight)
painter.drawPixmap(0,
cSizeH // 2 - scaledLogo.height() // 2,
scaledLogo)
else:
painter.drawPixmap((cSizeW - bgLogoW) // 2,
(cSizeH - bgLogoH) // 2,
self.bgLogo)
else:
# Center the pixmap
dx = (rect.width() - self.bgLogo.width()) / 2
dy = (rect.height() - self.bgLogo.height()) / 2
painter.drawPixmap(dx, dy,
self.bgLogo.width(), self.bgLogo.height(),
self.bgLogo)
示例11: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, event):
QToolButton.paintEvent(self, event)
p = QPainter(self)
p.setRenderHint(QPainter.TextAntialiasing)
p.setRenderHint(QPainter.Antialiasing)
if self.badge_counter > 0x00:
point = self.rect().topRight()
self.drawBadge(
p,
point.x() - self.badge_size,
point.y(),
self.badge_size,
str(self.badge_counter),
QBrush(self.redGradient),
)
示例12: svg2icon
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def svg2icon(path, img_type=QImage):
img = QImage(64, 64, QImage.Format_ARGB32)
svgrenderer = QSvgRenderer(path)
paint = QPainter(img)
paint.setRenderHint(QPainter.HighQualityAntialiasing)
paint.setRenderHint(QPainter.SmoothPixmapTransform)
paint.setBrush(QColor(255, 255, 255, 255))
paint.drawRect(QRect(-1, -1, 65, 65))
svgrenderer.render(paint)
paint.end()
if img_type == QImage:
return img
elif img_type == QPixmap:
pix = QPixmap
pix = pix.fromImage(img)
return pix
示例13: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, event):
"""
Handles the ``paintEvent`` event for :class:`AboutDialog`.
:param `event`: a `QPaintEvent` event to be processed.
"""
rect = self.rect()
painter = QPainter(self)
painter.setRenderHint(painter.SmoothPixmapTransform)
# Always fill with a solid color first
painter.fillRect(rect, Qt.white)
# Then overlay the texture
painter.fillRect(rect, self.bgBrush)
示例14: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, event):
"""
This function handles the low level painting of component.
:param event:
:return:
"""
painter = QPainter()
painter.begin(self)
painter.setRenderHint(QPainter.Antialiasing)
if self.__flag == 1:
painter.end()
return
# setting the masking ellipse
painter.setClipRegion(self.__clip)
self.__color.setAlpha(self.__maxOpacity)
painter.setBrush(QBrush(self.__color))
painter.setPen(QPen(QColor(0, 0, 0, 0)))
painter.drawEllipse(self.__origin, self.__r, self.__r)
painter.end()
示例15: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setRenderHint [as 别名]
def paintEvent(self, event):
mouse_pos = self.mapFromGlobal(QCursor.pos())
is_hover = self.contentsRect().contains(mouse_pos)
if not self.new_ui:
QPushButton.paintEvent(self, event)
painter = QPainter(self)
if self.new_ui and self.isChecked():
painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(QPen(Qt.NoPen))
painter.setBrush(self.highlight)
painter.drawRoundedRect(event.rect(), 2, 2)
painter.drawPixmap(2, 2, self.icon)
if is_hover:
painter.setCompositionMode(QPainter.CompositionMode_Screen)
painter.drawPixmap(2, 2, self.icon)