def paintEvent(self, event ): """QToolBar.paintEvent reimplementation Draws buttons, dock icon and text """ rect = self._spacer.rect() painter = QPainter( self ) transform = QTransform() transform.translate(self._spacer.pos().x(), self._spacer.pos().y()) painter.setTransform( transform ) """ Not supported currently if self._dock.features() & QDockWidget.DockWidgetVerticalTitleBar : transform = QTransform() rect.setSize( QSize( rect.height(), rect.width() ) ) transform.rotate( -90 ) transform.translate( -rect.width(), 0 ) painter.setTransform( transform ) """ # icon / title optionB = QStyleOptionButton() optionB.initFrom( self._dock ) optionB.rect = rect optionB.text = self._dock.windowTitle() optionB.iconSize = self.iconSize() optionB.icon = self._dock.windowIcon() self.style().drawControl( QStyle.CE_PushButtonLabel, optionB, painter, self._dock )
def paintEvent(self, event): """QToolBar.paintEvent reimplementation Draws buttons, dock icon and text """ rect = self._spacer.rect() painter = QPainter(self) transform = QTransform() transform.translate(self._spacer.pos().x(), self._spacer.pos().y()) painter.setTransform(transform) """ Not supported currently if self._dock.features() & QDockWidget.DockWidgetVerticalTitleBar : transform = QTransform() rect.setSize(QSize(rect.height(), rect.width())) transform.rotate(-90) transform.translate(-rect.width(), 0) painter.setTransform(transform) """ # icon / title optionB = QStyleOptionButton() optionB.initFrom(self._dock) optionB.rect = rect optionB.text = self._dock.windowTitle() optionB.iconSize = self.iconSize() optionB.icon = self._dock.windowIcon() self.style().drawControl(QStyle.CE_PushButtonLabel, optionB, painter, self._dock)
def paintEvent(self, event): # reimplemented painter = QStylePainter(self) option = QStyleOptionButton() option.initFrom(self) option.icon = self.icon() option.iconSize = self.iconSize() icon = self.icon() if not icon.isNull(): if option.state & QStyle.State_Active: mode = (QIcon.Normal if option.state & QStyle.State_MouseOver else QIcon.Active) else: mode = QIcon.Disabled pixmap = icon.pixmap(option.iconSize, mode, ) painter.drawItemPixmap(option.rect, Qt.AlignCenter, pixmap)