def paint(self, painter, option, index): if index.column() == 0: painter.save() icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap(":/spotify/resources/icons/play_lgrey.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) palette = QApplication.palette() opt = QStyleOptionButton() opt.icon = icon opt.iconSize = QtCore.QSize(30, 30) opt.rect = option.rect color = palette.highlight().color() \ if option.state & QStyle.State_Selected \ else QtGui.QColor(index.model().data(index, Qt.BackgroundColorRole)) if self._pressed and self._pressed == (index.row(), index.column()): opt.state = QStyle.State_Enabled | QStyle.State_Sunken opt.icon = icon elif self._hover and self._hover == (index.row(), index.column()): print('oh man') opt.icon = icon else: opt.state = QStyle.State_Enabled | QStyle.State_Raised QApplication.style().drawControl(QStyle.CE_PushButtonLabel, opt, painter) painter.restore() else: QStyledItemDelegate.paint(self, painter, option, index)
def paintEvent(self, e): """ Draws the render setup button """ painter = QPainter(self) option = QStyleOptionButton() option.initFrom(self) if self.isDown(): option.state = QStyle.State_Sunken else: option.state = QStyle.State_Raised if self.enter: option.state = option.state | QStyle.State_MouseOver option.icon = self.icon() self.drawControl(QStyle.CE_PushButton, option, painter, self)