本文整理匯總了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)