def paintEvent(self, event: QPaintEvent) -> None: painter = QStylePainter(self) opt = QStyleOptionSlider() self.initStyleOption(opt) if self.tickPosition() != QSlider.NoTicks: x = 4 for i in range(self.minimum(), self.width(), x): if i % 5 == 0: h = 18 w = 1 z = 8 else: h = 7 w = 0.8 z = 15 pen = QPen(QColor('#444')) pen.setWidthF(w) painter.setPen(pen) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksAbove): y = self.rect().top() + z painter.drawLine(x, y, x, y + h) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksBelow): y = self.rect().bottom() - z painter.drawLine(x, y, x, y - h) x += 10 opt.subControls = QStyle.SC_SliderGroove painter.drawComplexControl(QStyle.CC_Slider, opt) for path in self._regions: brushcolor = QColor(150, 190, 78, 185) if self._regions.index(path) == self._regionSelected \ else QColor(237, 242, 255, 185) painter.setBrush(brushcolor) painter.setPen(Qt.NoPen) painter.drawPath(path) opt.subControls = QStyle.SC_SliderHandle painter.drawComplexControl(QStyle.CC_Slider, opt)
def paintEvent(self, arg1): p = QStylePainter(self) opt = QStyleOptionToolButton() self.initStyleOption(opt) # Disable the menu arrow, since we already got a down arrow icon opt.features &= ~QStyleOptionToolButton.HasMenu p.drawComplexControl(QStyle.CC_ToolButton, opt)
def paintEvent(self, event: QPaintEvent) -> None: painter = QStylePainter(self) opt = QStyleOptionSlider() self.initStyleOption(opt) if self.tickPosition() != QSlider.NoTicks: x = 4 for i in range(self.minimum(), self.width(), x): if i % 5 == 0: h = 18 w = 1 z = 8 else: h = 7 w = 0.8 z = 15 pen = QPen(QColor('#444')) pen.setWidthF(w) painter.setPen(pen) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksAbove): y = self.rect().top() + z painter.drawLine(x, y, x, y + h) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksBelow): y = self.rect().bottom() - z painter.drawLine(x, y, x, y - h) x += 10 opt.subControls = QStyle.SC_SliderGroove painter.drawComplexControl(QStyle.CC_Slider, opt) opt.subControls = QStyle.SC_SliderHandle painter.drawComplexControl(QStyle.CC_Slider, opt)
def paintEvent(self, event: QPaintEvent) -> None: painter = QStylePainter(self) opt = QStyleOptionSlider() self.initStyleOption(opt) handle = self.style.subControlRect(self.style.CC_Slider, opt, self.style.SC_SliderHandle, self) interval = self.tickInterval() if interval == 0: interval = self.pageStep() if self.tickPosition() != QSlider.NoTicks: for i in range(self.minimum(), self.maximum(), interval): x = round((((i - self.minimum()) / (self.maximum() - self.minimum())) * (self.width() - handle.width()) + (handle.width() / 2.0))) - 1 if i % 500000 == 0: h = 12 z = 5 else: h = 6 z = 11 painter.setPen(QColor('#484640')) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksAbove): y = self.rect().top() + z painter.drawLine(x, y, x, y + h) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksBelow): y = self.rect().bottom() - z painter.drawLine(x, y, x, y - h) opt.subControls = QStyle.SC_SliderGroove painter.drawComplexControl(QStyle.CC_Slider, opt) opt.subControls = QStyle.SC_SliderHandle painter.drawComplexControl(QStyle.CC_Slider, opt)
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()
def paintEvent(self, event: QPaintEvent) -> None: painter = QStylePainter(self) opt = QStyleOptionSlider() self.initStyleOption(opt) font = painter.font() font.setPixelSize(10) painter.setFont(font) if self.tickPosition() != QSlider.NoTicks: x = 8 for i in range(self.minimum(), self.width(), 8): if i % 5 == 0: h = 18 w = 1 z = 13 else: h = 8 w = 1 z = 23 tickcolor = '#8F8F8F' if self.theme == 'dark' else '#444' pen = QPen(QColor(tickcolor)) pen.setWidthF(w) painter.setPen(pen) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksAbove): y = self.rect().top() + z painter.drawLine(x, y, x, y + h) if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksBelow): y = self.rect().bottom() - z painter.drawLine(x, y, x, y - h) if self.parent.mediaAvailable and i % 15 == 0: painter.setPen(Qt.white if self.theme == 'dark' else Qt.black) timecode = QStyle.sliderValueFromPosition( self.minimum(), self.maximum(), x - self.offset, self.width() - (self.offset * 2)) timecode = self.parent.delta2QTime(timecode).toString( self.parent.runtimeformat) painter.drawText(x + 6, y + 6, timecode) if x + 30 > self.width(): break x += 15 opt.subControls = QStyle.SC_SliderGroove painter.drawComplexControl(QStyle.CC_Slider, opt) for rect in self._regions: rect.setY(int((self.height() - self._regionHeight) / 2) - 8) rect.setHeight(self._regionHeight) if self._regions.index(rect) == self._regionSelected: brushcolor = QColor(150, 190, 78, 185) else: brushcolor = QColor(237, 242, 255, 185) painter.setBrush(brushcolor) painter.setPen(QColor(255, 255, 255, 170)) painter.drawRect(rect) opt.subControls = QStyle.SC_SliderHandle painter.drawComplexControl(QStyle.CC_Slider, opt)
def paintEvent(self, event: QtGui.QPaintEvent) -> None: if not self.paint: return sp = QStylePainter(self) opt = QStyleOptionToolButton() self.initStyleOption(opt) opt.state |= (QStyle.State_MouseOver | QStyle.State_AutoRaise | QStyle.State_Raised) # type: ignore opt.activeSubControls |= QStyle.SC_ToolButton # type: ignore sp.drawComplexControl(QStyle.CC_ToolButton, opt)
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)
def paintEvent(self, event): painter = QStylePainter(self) opt = QStyleOptionComboBox() self.initStyleOption(opt) selected = [] for index in range(self.__model.rowCount()): item = self.__model.item(index) if item.checkState() == Qt.Checked: selected.append(item.text()) opt.currentText = " | ".join(selected) painter.drawComplexControl(QStyle.CC_ComboBox, opt) painter.drawControl(QStyle.CE_ComboBoxLabel, opt)
def paintEvent(self, event): """Reimplemented.""" painter = QStylePainter(self) option = QStyleOptionComboBox() self.initStyleOption(option) painter.drawComplexControl(QStyle.CC_ComboBox, option) # draw the icon and text checked = self.checkedIndices() if checked: items = [self.itemText(i) for i in checked] option.currentText = self.__separator.join(items) else: option.currentText = self.__placeholderText option.palette.setCurrentColorGroup(QPalette.Disabled) option.currentIcon = QIcon() painter.drawControl(QStyle.CE_ComboBoxLabel, option)
def paintEvent(self, e): painter = QStylePainter(self) painter.setPen(self.palette().color(QPalette.Text)) opt = QStyleOptionComboBox() self.initStyleOption(opt) count = self.model().checkedCount() if count == 0: opt.currentText = self.emptyCheckText elif count == 3: opt.currentText = self.model().singleCheckText else: opt.currentText = self.fullCheckText painter.drawComplexControl(QStyle.CC_ComboBox, opt) painter.drawControl(QStyle.CE_ComboBoxLabel, opt)
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)
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() == 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)
def paintEvent(self, paintEvent): painter = QStylePainter(self) painter.drawComplexControl(QStyle.CC_Slider, self._options.getGrooveOptions()) painter.drawComplexControl(QStyle.CC_Slider, self._options.getLowerHandleOptions()) painter.drawComplexControl(QStyle.CC_Slider, self._options.getUpperHandleOptions())
def paintEvent(self, event): painter = QStylePainter(self) option = QStyleOptionToolButton() self.initStyleOption(option) option.features &= ~QStyleOptionToolButton.HasMenu painter.drawComplexControl(QStyle.CC_ToolButton, option)
def paintEvent(self, paintEvent): painter = QStylePainter(self) painter.drawComplexControl(QStyle.CC_Slider, self._options.getGrooveOptions()) painter.drawComplexControl(QStyle.CC_Slider, self._options.getLowerHandleOptions()) painter.drawComplexControl(QStyle.CC_Slider, self._options.getUpperHandleOptions())
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)
def paintEvent(self, event): painter = QStylePainter(self) option = QStyleOptionToolButton() self.initStyleOption(option) option.features &= ~QStyleOptionToolButton.HasMenu painter.drawComplexControl(QStyle.CC_ToolButton, option)
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)