gpt4 book ai didi

python - PyQt:更改 QTableView 中复选框的对齐方式

转载 作者:太空宇宙 更新时间:2023-11-03 12:10:20 24 4
gpt4 key购买 nike

我有一个带有复选框的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++ 示例?

最佳答案

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

关于python - PyQt:更改 QTableView 中复选框的对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2965855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com