def paintSection(self, painter, rect, logicalIndex): ''' The method paint the robot or capability images in the backgroud of the cell. :see: U{QtGui.QHeaderView.paintSection()<https://srinikom.github.io/pyside-docs/PySide/QtGui/QHeaderView.html#PySide.QtGui.PySide.QtGui.QHeaderView.paintSection>} ''' painter.save() QHeaderView.paintSection(self, painter, rect, logicalIndex) painter.restore() if logicalIndex in range(len( self._data)) and self._data[logicalIndex]['images']: if len(self._data[logicalIndex]['images']) == 1: pix = self._data[logicalIndex]['images'][0] pix = pix.scaled(rect.width(), rect.height() - 20, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.style().drawItemPixmap(painter, rect, 5, pix) elif len(self._data[logicalIndex]['images']) > 1: new_rect = QRect(rect.left(), rect.top(), rect.width(), (rect.height() - 20) / 2.) pix = self._data[logicalIndex]['images'][0] pix = pix.scaled(new_rect.width(), new_rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation) self.style().drawItemPixmap(painter, new_rect, 5, pix) new_rect = QRect(rect.left(), rect.top() + new_rect.height(), rect.width(), new_rect.height()) pix = self._data[logicalIndex]['images'][1] pix = pix.scaled(new_rect.width(), new_rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation) self.style().drawItemPixmap(painter, new_rect, 5, pix)
def paintSection(self, painter, rect, logicalIndex): ''' The method paint the robot or capability images in the backgroud of the cell. @see: U{QtGui.QHeaderView.paintSection()<https://srinikom.github.io/pyside-docs/PySide/QtGui/QHeaderView.html#PySide.QtGui.PySide.QtGui.QHeaderView.paintSection>} ''' painter.save() QHeaderView.paintSection(self, painter, rect, logicalIndex) painter.restore() if logicalIndex in range(len(self._data)) and self._data[logicalIndex]['images']: if len(self._data[logicalIndex]['images']) == 1: pix = self._data[logicalIndex]['images'][0] pix = pix.scaled(rect.width(), rect.height() - 20, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.style().drawItemPixmap(painter, rect, 5, pix) elif len(self._data[logicalIndex]['images']) > 1: new_rect = QRect(rect.left(), rect.top(), rect.width(), (rect.height() - 20) / 2.) pix = self._data[logicalIndex]['images'][0] pix = pix.scaled(new_rect.width(), new_rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation) self.style().drawItemPixmap(painter, new_rect, 5, pix) new_rect = QRect(rect.left(), rect.top() + new_rect.height(), rect.width(), new_rect.height()) pix = self._data[logicalIndex]['images'][1] pix = pix.scaled(new_rect.width(), new_rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation) self.style().drawItemPixmap(painter, new_rect, 5, pix)