def paintEvent(self, _):  # pragma: no cover
        """Override to apply "background-color" property of QWidget"""

        opt = QStyleOption()
        opt.initFrom(self)
        painter = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
예제 #2
0
    def paintEvent(self, _):
        """Override paintEvent to paint background"""

        opt = QStyleOption()
        opt.initFrom(self)
        painter = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
예제 #3
0
    def paintEvent(self, *args, **kwargs):
        o = QStyleOption()
        o.initFrom(self)
        p = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, o, p, self)

        return QWidget.paintEvent(self, *args, **kwargs)
예제 #4
0
    def paintEvent(self, _):  # pragma: no cover
        """Override to apply "background-color" property of QWidget"""

        opt = QStyleOption()
        opt.initFrom(self)
        painter = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
예제 #5
0
    def setToolbarButtonLook(self, enable):
        if enable:
            self._options |= self._ToolBarLookOption

            opt = QStyleOption()
            opt.initFrom(self)
            size = self.style().pixelMetric(QStyle.PM_ToolBarIconSize, opt, self)
            self.setIconSize(QSize(size, size))
        else:
            self._options &= ~self._ToolBarLookOption

        self.setProperty('toolbar-look', enable)
        self.style().unpolish(self)
        self.style().polish(self)
예제 #6
0
 def paintEvent(self, event):
     opt = QStyleOption()
     opt.initFrom(self)
     painter = QPainter(self)
     self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
    def paintEvent(self, event):
        '''
        @param: event QPaintEvent
        '''
        p = QPainter(self)

        # Just draw separator
        if self._bookmark.isSeparator():
            opt = QStyleOption()
            opt.initFrom(self)
            opt.state |= QStyle.State_Horizontal
            self.style().drawPrimitive(QStyle.PE_IndicatorToolBarSeparator,
                                       opt, p)
            return

        option = QStyleOptionButton()
        self.initStyleOption(option)

        # We are manually drawing the arrow
        option.features &= ~QStyleOptionButton.HasMenu

        # Draw button base (only under mouse, this is autoraise button)
        if self.isDown() or self.hitButton(self.mapFromGlobal(QCursor.pos())):
            option.state |= QStyle.State_AutoRaise | QStyle.State_Raised
            self.style().drawPrimitive(QStyle.PE_PanelButtonTool, option, p,
                                       self)

        if self.isDown():
            shiftX = self.style().pixelMetric(QStyle.PM_ButtonShiftHorizontal,
                                              option, self)
            shiftY = self.style().pixelMetric(QStyle.PM_ButtonShiftVertical,
                                              option, self)
        else:
            shiftX = 0
            shiftY = 0

        height = option.rect.height()
        center = height / 2 + option.rect.top() + shiftY

        iconSize = 16
        iconYPos = center - iconSize / 2

        leftPosition = self.PADDING + shiftX
        rightPosition = option.rect.right() - self.PADDING

        # Draw icon
        if not self._showOnlyText:
            iconRect = QRect(leftPosition, iconYPos, iconSize, iconSize)
            p.drawPixmap(
                QStyle.visualRect(option.direction, option.rect, iconRect),
                self._bookmark.icon().pixmap(iconSize))
            leftPosition = iconRect.right() + self.PADDING

        # Draw menu arrow
        if not self._showOnlyIcon and self.menu():
            arrowSize = 8
            opt = QStyleOption()
            opt.initFrom(self)
            rect = QRect(rightPosition - 8, center - arrowSize / 2, arrowSize,
                         arrowSize)
            opt.rect = QStyle.visualRect(option.direction, option.rect, rect)
            opt.state &= ~QStyle.State_MouseOver
            self.style().drawPrimitive(QStyle.PE_IndicatorArrowDown, opt, p,
                                       self)
            rightPosition = rect.left() - self.PADDING

        # Draw text
        if not self._showOnlyIcon:
            textWidth = rightPosition - leftPosition
            textYPos = center - self.fontMetrics().height() / 2
            txt = self.fontMetrics().elidedText(self._bookmark.title(),
                                                Qt.ElideRight, textWidth)
            textRect = QRect(leftPosition, textYPos, textWidth,
                             self.fontMetrics().height())
            self.style().drawItemText(
                p, QStyle.visualRect(option.direction, option.rect, textRect),
                Qt.TextSingleLine | Qt.AlignCenter, option.palette, True, txt)
예제 #8
0
 def paintEvent(self, event):
     opt = QStyleOption()
     opt.initFrom(self)
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing)
     self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)