【发布时间】:2011-02-27 07:04:28
【问题描述】:
我有一个带有复选框的QTableView,但复选框左对齐,我需要将其居中对齐。我试过this,但“检查”功能有问题:
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++ 示例?
【问题讨论】:
标签: python checkbox pyqt alignment qtreeview