我有一个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++ 示例?