Пример #1
0
 def paintEvent(self, event):
     p = QStylePainter(self)
     opt = QStyleOptionToolButton()
     self.initStyleOption(opt)
     if self.__text:
         # Replace the text
         opt.text = self.__text
     p.drawComplexControl(QStyle.CC_ToolButton, opt)
     p.end()
Пример #2
0
 def paintEvent(self, event):
     p = QStylePainter(self)
     opt = QStyleOptionToolButton()
     self.initStyleOption(opt)
     if self.__text:
         # Replace the text
         opt.text = self.__text
     p.drawComplexControl(QStyle.CC_ToolButton, opt)
     p.end()
Пример #3
0
    def paintEvent( self, _ ):
        painter = QStylePainter( self )
        painter.setPen( self.palette().color( QPalette.Text ) )

        opt = QStyleOptionComboBox()
        self.initStyleOption( opt )
        painter.drawComplexControl( QStyle.CC_ComboBox, opt )

        frame = self.style().subControlRect( QStyle.CC_ComboBox, opt, QStyle.SC_ComboBoxEditField, self )
        painter.setRenderHint( QPainter.Antialiasing )
        painter.setPen( Qt.transparent )
        painter.setBrush( self.color() )
        painter.drawRoundedRect( frame.adjusted( 1, 1, -1, -2 ), 2, 2 )
    def paintEvent(self, event):
        opt = QStyleOptionToolButton()
        self.initStyleOption(opt)
        if self.__showMenuIndicator and self.isChecked():
            opt.features |= QStyleOptionToolButton.HasMenu
        if self.__flat:
            # Use default widget background/border styling.
            StyledWidget_paintEvent(self, event)

            p = QStylePainter(self)
            p.drawControl(QStyle.CE_ToolButtonLabel, opt)
        else:
            p = QStylePainter(self)
            p.drawComplexControl(QStyle.CC_ToolButton, opt)
Пример #5
0
    def paintEvent(self, event):
        opt = QStyleOptionToolButton()
        self.initStyleOption(opt)
        if self.__showMenuIndicator and self.isChecked():
            opt.features |= QStyleOptionToolButton.HasMenu
        if self.__flat:
            # Use default widget background/border styling.
            StyledWidget_paintEvent(self, event)

            p = QStylePainter(self)
            p.drawControl(QStyle.CE_ToolButtonLabel, opt)
        else:
            p = QStylePainter(self)
            p.drawComplexControl(QStyle.CC_ToolButton, opt)
Пример #6
0
    def paintEvent(self, _):
        painter = QStylePainter(self)
        painter.setPen(self.palette().color(QPalette.Text))

        opt = QStyleOptionComboBox()
        self.initStyleOption(opt)
        painter.drawComplexControl(QStyle.CC_ComboBox, opt)

        frame = self.style().subControlRect(QStyle.CC_ComboBox, opt,
                                            QStyle.SC_ComboBoxEditField, self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(Qt.transparent)
        painter.setBrush(self.color())
        painter.drawRoundedRect(frame.adjusted(1, 1, -1, -2), 2, 2)
Пример #7
0
    def paintEvent(self, event):
        painter = QStylePainter(self)

        # ticks
        opt = QStyleOptionSlider()
        self.initStyleOption(opt)
        opt.subControls = QStyle.SC_SliderTickmarks
        painter.drawComplexControl(QStyle.CC_Slider, opt)

        # groove
        opt.sliderPosition = 20
        opt.sliderValue = 0
        opt.subControls = QStyle.SC_SliderGroove
        painter.drawComplexControl(QStyle.CC_Slider, opt)

        # handle rects
        opt.sliderPosition = self.lowerPos
        lr = self.style().subControlRect(QStyle.CC_Slider, opt,
                                         QStyle.SC_SliderHandle, self)
        lrv = self.pick(lr.center())
        opt.sliderPosition = self.upperPos
        ur = self.style().subControlRect(QStyle.CC_Slider, opt,
                                         QStyle.SC_SliderHandle, self)
        urv = self.pick(ur.center())

        # span
        minv = min(lrv, urv)
        maxv = max(lrv, urv)
        c = self.style().subControlRect(QStyle.CC_Slider, opt,
                                        QStyle.SC_SliderGroove, self).center()
        spanRect = QRect(QPoint(c.x() - 2, minv), QPoint(c.x() + 1, maxv))
        if self.orientation() == QtCore.Qt.Horizontal:
            spanRect = QRect(QPoint(minv, c.y() - 2), QPoint(maxv, c.y() + 1))
        self.drawSpan(painter, spanRect)

        # handles
        if self.lastPressed == QxtSpanSlider.LowerHandle:
            self.drawHandle(painter, QxtSpanSlider.UpperHandle)
            self.drawHandle(painter, QxtSpanSlider.LowerHandle)
        else:
            self.drawHandle(painter, QxtSpanSlider.LowerHandle)
            self.drawHandle(painter, QxtSpanSlider.UpperHandle)
Пример #8
0
 def paintEvent(self, e):
     data = self.itemData(self.currentIndex(), Qt.UserRole)
     if data.isValid() and data.toPyObject() is not None:
         data = data.toPyObject()
         p = QStylePainter(self)
         p.setPen(self.palette().color(QPalette.Text))
         opt = QStyleOptionComboBox()
         self.initStyleOption(opt)
         p.drawComplexControl(QStyle.CC_ComboBox, opt)
         painter = QPainter(self)
         painter.save()
         rect = p.style().subElementRect(QStyle.SE_ComboBoxFocusRect, opt, self)
         rect.adjust(+5, 0, -5, 0)
         pen = data
         painter.setPen(pen)
         middle = (rect.bottom() + rect.top()) / 2
         painter.drawLine(rect.left(), middle, rect.right(), middle)
         painter.restore()
     else:
         QComboBox.paintEvent(self, e)
Пример #9
0
    def paintEvent(self, event):
        painter = QStylePainter(self)

        # ticks
        opt = QStyleOptionSlider()
        self.initStyleOption(opt)
        opt.subControls = QStyle.SC_SliderTickmarks
        painter.drawComplexControl(QStyle.CC_Slider, opt)

        # groove
        opt.sliderPosition = 20
        opt.sliderValue = 0
        opt.subControls = QStyle.SC_SliderGroove
        painter.drawComplexControl(QStyle.CC_Slider, opt)

        # handle rects
        opt.sliderPosition = self.lowerPos
        lr = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderHandle, self)
        lrv = self.pick(lr.center())
        opt.sliderPosition = self.upperPos
        ur = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderHandle, self)
        urv = self.pick(ur.center())

        # span
        minv = min(lrv, urv)
        maxv = max(lrv, urv)
        c = self.style().subControlRect(QStyle.CC_Slider, opt,
                                        QStyle.SC_SliderGroove, self).center()
        spanRect = QRect(QPoint(c.x() - 2, minv), QPoint(c.x() + 1, maxv))
        if self.orientation() == QtCore.Qt.Horizontal:
            spanRect = QRect(QPoint(minv, c.y() - 2), QPoint(maxv, c.y() + 1))
        self.drawSpan(painter, spanRect)

        # handles
        if self.lastPressed == QxtSpanSlider.LowerHandle:
            self.drawHandle(painter, QxtSpanSlider.UpperHandle)
            self.drawHandle(painter, QxtSpanSlider.LowerHandle)
        else:
            self.drawHandle(painter, QxtSpanSlider.LowerHandle)
            self.drawHandle(painter, QxtSpanSlider.UpperHandle)
Пример #10
0
    def paintEvent(self, event):
        # based on
        # https://github.com/qt/qtbase/blob/f40dbe0d0b54ce83d2168e82905cf4f75059a841/src/widgets/widgets/qslider.cpp#L315
        # https://github.com/enthought/traitsui/blob/master/traitsui/qt4/extra/range_slider.py
        painter = QStylePainter(self)
        minpos = self.__min_position
        maxpos = self.__max_position

        # Draw the groove
        opt = QStyleOptionSlider()
        self.initStyleOption(opt)
        # Draw empty grove
        opt.sliderPosition = opt.minimum
        opt.subControls = QStyle.SC_SliderGroove
        if self.tickPosition() != self.NoTicks:
            opt.subControls |= QStyle.SC_SliderTickmarks
        painter.drawComplexControl(QStyle.CC_Slider, opt)
        # Draw the highlighted part on top
        # Qt4.8 and Qt5.3 draw the highlighted groove in a weird way because they
        # transpose opt.rect. Qt5.7 works fine.
        if QT_VERSION_STR >= '5.7.0':
            opt.subControls = QStyle.SC_SliderGroove
            opt.sliderPosition = opt.maximum
            if self.orientation() == Qt.Horizontal:
                _w = opt.rect.width() / opt.maximum
                x = round(_w * minpos)
                w = round(_w * (maxpos - minpos))
                opt.rect = QRect(x, 0, w, opt.rect.height())
            else:
                _h = opt.rect.height() / opt.maximum
                y = round(_h * minpos)
                h = round(_h * (maxpos - minpos))
                opt.rect = QRect(0, y, opt.rect.width(), h)
            painter.drawComplexControl(QStyle.CC_Slider, opt)

        # Draw the handles
        for i, position in enumerate((minpos, maxpos)):
            opt = QStyleOptionSlider()
            self.initStyleOption(opt)
            opt.subControls = QStyle.SC_SliderHandle

            if self.__pressed_control and (self.__active_slider == i or
                                           self.__active_slider < 0):
                opt.activeSubControls = self.__pressed_control
                opt.state |= QStyle.State_Sunken
            else:
                opt.activeSubControls = self.__hovered_control

            opt.sliderPosition = position
            opt.sliderValue = position
            painter.drawComplexControl(QStyle.CC_Slider, opt)
Пример #11
0
 def paintEvent(self, event):
     painter = QStylePainter(self)
     option = QStyleOptionToolButton()
     self.initStyleOption(option)
     option.icon = self.animation_icons[self.animation_icon_index]
     painter.drawComplexControl(QStyle.CC_ToolButton, option)
Пример #12
0
 def paintEvent(self, event):
     painter = QStylePainter(self)
     option = QStyleOptionToolButton()
     self.initStyleOption(option)
     option.features &= ~QStyleOptionToolButton.HasMenu
     painter.drawComplexControl(QStyle.CC_ToolButton, option)
Пример #13
0
 def paintEvent(self, event):
     painter = QStylePainter(self)
     option = QStyleOptionToolButton()
     self.initStyleOption(option)
     option.icon = self.animation_icons[self.animation_icon_index]
     painter.drawComplexControl(QStyle.CC_ToolButton, option)
Пример #14
0
 def paintEvent(self, event):
     painter = QStylePainter(self)
     option = QStyleOptionToolButton()
     self.initStyleOption(option)
     option.features &= ~QStyleOptionToolButton.HasMenu
     painter.drawComplexControl(QStyle.CC_ToolButton, option)