Python AttributeError: 'QCheckBox' object has no attribute 'ischecked'

Python AttributeError: 'QCheckBox' object has no attribute 'ischecked'

我已经为我的问题创建了一个最小的可重现示例。我不明白为什么会显示 AttributeError: 'QCheckBox' object has no attribute 'ischecked' 有人可以帮我理解这个问题和任何解决方案吗?

示例:

from PyQt5.QtWidgets import *
import sys


class a:
    
    def __init__(self):
        super().__init__()
        
        self.checkboxes_items = {
            'this': False,
            'that': True
        }
        
    def checkboxes(self):
        self.checkboxes_items_list = []
        for item, val in self.checkboxes_items.items():
            chkbox = QCheckBox()
            chkbox.setText(item)
            chkbox.setChecked(val)
            self.checkboxes_items_list.append(chkbox)  # Add to list
        for x in self.checkboxes_items_list:
            print(x.ischecked())                    # This line causes the issue


if __name__ == "__main__":
    app = QApplication(sys.argv)
    class_inst = a()
    class_inst.checkboxes()
    app.exec()

注意:我尝试使用 self.chkbox 而不是 chkbox。但没有帮助。

根据 [Qt.Doc]: List of All Members for QCheckBox,方法(继承自 QAbstractButton)名称为 isChecked (1st C 大写),所以该行应该是:

print(x.isChecked())