4
我有一個QTableView
與複選框,但複選框左對齊,我需要對齊它的中心。我試過this,但我與「檢查」功能相關的問題:PyQt:更改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)
什麼是「檢查」功能?我如何在PyQt中重新實現C++示例?