【问题标题】:PyQt: change the alignment of checkboxes in a QTableViewPyQt:更改 QTableView 中复选框的对齐方式
【发布时间】: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


    【解决方案1】:

    您链接到的示例代码没有check 函数-可能是已修复的错字吗?或者它可能是代码本身定义的函数,而不是Qt 的一部分?

    【讨论】:

      猜你喜欢
      • 2013-07-18
      • 1970-01-01
      • 2020-04-20
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 2018-08-08
      • 1970-01-01
      • 2016-07-16
      相关资源
      最近更新 更多