Python PyQt5.QtWidgets.QStyleOption() Examples

The following are 16 code examples for showing how to use PyQt5.QtWidgets.QStyleOption(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: track   Author: frans-fuerst   File: qreordertableview.py    License: Apache License 2.0 6 votes vote down vote up
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) 
Example 2
Project: urh   Author: jopohl   File: GeneratorTableView.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 3
Project: argos   Author: titusjan   File: misc.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 4
Project: parsec-cloud   Author: Scille   File: custom_dialogs.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def paintEvent(self, event):
        opt = QStyleOption()
        opt.initFrom(self)
        p = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self) 
Example 5
Project: parsec-cloud   Author: Scille   File: menu_widget.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def paintEvent(self, _):
        opt = QStyleOption()
        opt.initFrom(self)
        p = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self) 
Example 6
def paintEvent(self, _):
        opt = QStyleOption()
        opt.initFrom(self)
        p = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self) 
Example 7
def paintEvent(self, _):
        opt = QStyleOption()
        opt.initFrom(self)
        p = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self) 
Example 8
Project: eddy   Author: danielepantaleone   File: dock.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 9
Project: eddy   Author: danielepantaleone   File: welcome.py    License: GNU General Public License v3.0 5 votes vote down vote up
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
    ################################# 
Example 10
Project: eddy   Author: danielepantaleone   File: welcome.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 11
Project: eddy   Author: danielepantaleone   File: palette.py    License: GNU General Public License v3.0 5 votes vote down vote up
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
    ################################# 
Example 12
Project: eddy   Author: danielepantaleone   File: info.py    License: GNU General Public License v3.0 5 votes vote down vote up
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
################################# 
Example 13
Project: eddy   Author: danielepantaleone   File: project_explorer.py    License: GNU General Public License v3.0 5 votes vote down vote up
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
    ################################# 
Example 14
Project: photobooth   Author: reuterbal   File: Widgets.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
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() 
Example 15
Project: Pythonic   Author: hANSIc99   File: element_iconbar.py    License: GNU General Public License v3.0 5 votes vote down vote up
def paintEvent(self, event):
        
        style_opt = QStyleOption()
        style_opt.initFrom(self)
        painter = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, style_opt, painter, self) 
Example 16
Project: PyQt   Author: PyQt5   File: CustomPaintWidget.py    License: GNU General Public License v3.0 5 votes vote down vote up
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)