I\'m trying to read in an xml file and populate a QListWidget
with some of its contents. Each entry should have a checkbox.
In Qt Designer I created the lis
You're almost there: it's just that you're trying to make the list-widget checkable, rather than each list-widget-item.
Try this instead:
from PyQt5 import QtWidgets, QtCore
self.listWidgetTestCases = QtWidgets.QListWidget()
for testcases in root.iter('testcase'):
testcase_name = str(testcases.attrib)
item = QtWidgets.QListWidgetItem(testcase_name)
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
item.setCheckState(QtCore.Qt.Unchecked)
self.listWidgetTestCases.addItem(item)
(NB: for PyQt4, use QtGui instead of QtWidgets)