我正在尝试重新实现QCheckBox的hitButton方法,以便只有实际的复选框(即不是标签)是可点击的。我不精通 C++,但查看QCheckBox的源代码,我尝试在 python 中重新实现现有代码,看看我是否可以让它按照我想要的方式工作。我的想法是我只需要更改SE_CheckBoxClickRect为SE_CheckBoxIndicator. 下面的内容似乎只在复选标记框的一个很小的区域内有效,在其他任何地方都没有:class ClickCheckBox(QCheckBox): """subclass to reimplement hitButton""" def __init__(self, *args): super(ClickCheckBox, self).__init__(*args) def hitButton(self, QPoint): style = QStyle.SE_CheckBoxClickRect opt = QStyleOptionButton() return QApplication.style().subElementRect(style, opt, self).contains(QPoint)我怎样才能使这项工作?
添加回答
举报
0/150
提交
取消