本文整理汇总了Python中PyQt5.QtWidgets.QStyleOption方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QStyleOption方法的具体用法?Python QtWidgets.QStyleOption怎么用?Python QtWidgets.QStyleOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QStyleOption方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawPrimitive
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def drawPrimitive(
self,
element: QtWidgets.QStyle.PrimitiveElement,
option: QtWidgets.QStyleOption,
painter: QtGui.QPainter,
widget: QtWidgets.QWidget = None) -> None:
"""Draw a line across the entire row rather than just the column we're hovering over.
This may not always work depending on global style - for instance I think it won't
work on OSX."""
if element == self.PE_IndicatorItemViewItemDrop and not option.rect.isNull():
option_new = QtWidgets.QStyleOption(option)
option_new.rect.setLeft(0)
if widget:
option_new.rect.setRight(widget.width())
option = option_new
super().drawPrimitive(element, option, painter, widget)
示例2: paint_drop_indicator
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paint_drop_indicator(self, painter):
if self.drag_active:
opt = QStyleOption()
opt.initFrom(self)
opt.rect = self.drop_indicator_rect
rect = opt.rect
brush = QBrush(QColor(Qt.darkRed))
if rect.height() == 0:
pen = QPen(brush, 2, Qt.SolidLine)
painter.setPen(pen)
painter.drawLine(rect.topLeft(), rect.topRight())
else:
pen = QPen(brush, 2, Qt.SolidLine)
painter.setPen(pen)
painter.drawRect(rect)
示例3: widgetSubCheckBoxRect
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def widgetSubCheckBoxRect(widget, option):
""" Returns the rectangle of a check box drawn as a sub element of widget
"""
opt = QtWidgets.QStyleOption()
opt.initFrom(widget)
style = widget.style()
return style.subElementRect(QtWidgets.QStyle.SE_ViewItemCheckIndicator, opt, widget)
示例4: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, event):
opt = QStyleOption()
opt.initFrom(self)
p = QPainter(self)
self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self)
示例5: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, _):
opt = QStyleOption()
opt.initFrom(self)
p = QPainter(self)
self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self)
示例6: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, paintEvent):
"""
This is needed for the widget to pick the stylesheet.
:type paintEvent: QPaintEvent
"""
option = QtWidgets.QStyleOption()
option.initFrom(self)
painter = QtGui.QPainter(self)
style = self.style()
style.drawPrimitive(QtWidgets.QStyle.PE_Widget, option, painter, self)
示例7: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, paintEvent):
"""
This is needed for the widget to pick the stylesheet.
:type paintEvent: QPaintEvent
"""
option = QtWidgets.QStyleOption()
option.initFrom(self)
painter = QtGui.QPainter(self)
style = self.style()
style.drawPrimitive(QtWidgets.QStyle.PE_Widget, option, painter, self)
#############################################
# SLOTS
#################################
示例8: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, paintEvent):
"""
This is needed for the widget to pick the stylesheet.
:type paintEvent: QPaintEvent
"""
option = QtWidgets.QStyleOption()
option.initFrom(self)
painter = QtGui.QPainter(self)
style = self.style()
style.drawPrimitive(QtWidgets.QStyle.PE_Widget, option, painter, self)
#############################################
# INTERFACE
#################################
示例9: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, paintEvent):
"""
This is needed for the widget to pick the stylesheet.
:type paintEvent: QPaintEvent
"""
option = QtWidgets.QStyleOption()
option.initFrom(self)
painter = QtGui.QPainter(self)
style = self.style()
style.drawPrimitive(QtWidgets.QStyle.PE_Widget, option, painter, self)
#############################################
# INFO WIDGETS
#################################
示例10: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, event):
opt = QtWidgets.QStyleOption()
opt.initFrom(self)
painter = QtGui.QPainter(self)
self.style().drawPrimitive(QtWidgets.QStyle.PE_Widget, opt, painter,
self)
painter.end()
示例11: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, event):
style_opt = QStyleOption()
style_opt.initFrom(self)
painter = QPainter(self)
self.style().drawPrimitive(QStyle.PE_Widget, style_opt, painter, self)
示例12: paintEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QStyleOption [as 别名]
def paintEvent(self, event):
# 解决QSS问题
option = QStyleOption()
option.initFrom(self)
painter = QPainter(self)
self.style().drawPrimitive(QStyle.PE_Widget, option, painter, self)
super(CustomPaintWidget, self).paintEvent(event)