J'ai une QTableView
avec la case à cocher, mais la case à cocher est aligné à gauche, et je dois aligner le centre. J'ai essayé this, mais j'ai un problème avec la fonction « vérifier »:PyQt: modifier l'alignement des cases à cocher dans un QTableView
def drawCheck(self, painter, option, rect, state):
textMargin = QtGui.QApplication.style().pixelMetric(QtGui.QStyle.PM_FocusFrameHMargin) + 1
checkRect = QtGui.QStyle.alignedRect(option.direction, QtCore.Qt.AlignCenter,
check(option, option.rect, QtCore.Qt.Checked).size(),
QtCore.QRect(option.rect.x() + textMargin, option.rect.y(),
option.rect.width() - (textMargin * 2), option.rect.height()))
QtGui.QItemDelegate.drawCheck(self, painter, checkRect, state)
Quelle est la fonction « check »? Comment puis-je réimplémenter l'exemple C++ dans PyQt?