How to get the checked items listed in a Qt QListWidget

后端 未结 1 1393
温柔的废话
温柔的废话 2021-01-20 20:23

I\'ve populated a QListWidget with a list of items and added a check box leaving everything unchecked.

for td in root.iter(\'testdata\'):
    test_data = td.         


        
1条回答
  •  无人共我
    2021-01-20 21:04

    You need to check if checkState is actually Qt.Checked:

    for index in range(self.listWidgetLabels.count()):
        if self.listWidgetLabels.item(index).checkState() == Qt.Checked:
            checked_items.append(self.listWidgetLabels.item(index))
    

    0 讨论(0)
提交回复
热议问题