def paintSection(self, painter, rect, logicalIndex): painter.save() super(SelectableTableHeader, self).paintSection(painter, rect, logicalIndex) painter.restore() if logicalIndex in self._nonSelectableIndexes: return # check if boolean for this section exists if not self._isSectionSelected.has_key(logicalIndex): if self._selectionModel: if self.orientation() == Qt.Horizontal: self._isSectionSelected[logicalIndex] = self._selectionModel.getColSelectionState(logicalIndex) elif self.orientation() == Qt.Vertical: self._isSectionSelected[logicalIndex] = self._selectionModel.getRowSelectionState(logicalIndex) else: self._isSectionSelected[logicalIndex] = Qt.Checked option = QStyleOptionButton() option.rect = rect if self._isSectionSelected[logicalIndex] == Qt.Checked: option.state = QStyle.State_On | QStyle.State_Enabled elif self._isSectionSelected[logicalIndex] == Qt.Unchecked: option.state = QStyle.State_Off | QStyle.State_Enabled elif self._isSectionSelected[logicalIndex] == Qt.PartiallyChecked: option.state = QStyle.State_NoChange | QStyle.State_Enabled self.style().drawControl(QStyle.CE_CheckBox, option, painter)
def paintSection(self, painter, rect, logicalIndex): painter.save() super(SelectableTableHeader, self).paintSection(painter, rect, logicalIndex) painter.restore() if logicalIndex in self._nonSelectableIndexes: return # check if boolean for this section exists if not self._isSectionSelected.has_key(logicalIndex): if self._selectionModel: if self.orientation() == Qt.Horizontal: self._isSectionSelected[ logicalIndex] = self._selectionModel.getColSelectionState( logicalIndex) elif self.orientation() == Qt.Vertical: self._isSectionSelected[ logicalIndex] = self._selectionModel.getRowSelectionState( logicalIndex) else: self._isSectionSelected[logicalIndex] = Qt.Checked option = QStyleOptionButton() option.rect = rect if self._isSectionSelected[logicalIndex] == Qt.Checked: option.state = QStyle.State_On | QStyle.State_Enabled elif self._isSectionSelected[logicalIndex] == Qt.Unchecked: option.state = QStyle.State_Off | QStyle.State_Enabled elif self._isSectionSelected[logicalIndex] == Qt.PartiallyChecked: option.state = QStyle.State_NoChange | QStyle.State_Enabled self.style().drawControl(QStyle.CE_CheckBox, option, painter)
def paintSection(self, painter, rect, logicalIndex): #painter.save() #QHeaderView.paintSection(self, painter, rect, logicalIndex) #painter.restore() if logicalIndex == 0: option = QStyleOptionButton() option.rect = QRect(1, 10, 10, 10) if self.isOn: option.state = QStyle.State_On else: option.state = QStyle.State_Off self.style().drawControl(QStyle.CE_CheckBox, option, painter)
def paint( self, painter, option, index ): super(VoxelGridDelegate,self).paint(painter, option, index) column = GridManagerColumns.Columns[index.column()] # The only change we present here, is a "fake" button (It is a button, but just in appearance), # to invoke the Color Picker Widget, in the Color column. if( column == GridManagerColumns.Color ): button = QStyleOptionButton() # It looks like a button, but similarities ends here. It's just a skin. button.rect = self._get_color_picker_button_dimensions(option.rect) button.text = "..."; # By the way, I couldn't change the color of the f***ing button. So i decided to use the background of the cell as the indicator button.state = QStyle.State_Enabled QApplication.style().drawControl( QStyle.CE_PushButton, button, painter )