Hi,
I'm using Python and trying to read in an xml file and populate a list QT ListWidget with some of its contents. Each entry should have a checkbox.
In QT I created the list and added an item that has a checkbox by adding the item to the listWidget, then right clicking on it and selecting Edit Items > Properties > Set Flags to UserCheckable. So i can do it manually in QT.
But when I read in the xml file to populate the ListWidget I can't make these items checkable.
import xml.etree.ElementTree as et
xml_file = os.path.join(path, testcase_file)
tree = et.parse(xml_file)
root = tree.getroot()
for testcases in root.iter('testcase'):
testcase_name = str(testcases.attrib)
item = self.listWidgetTestCases
item.addItem(QtGui.QApplication.translate("qadashb oard", testcase_name, None))
# item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
# item.setCheckState(QtCore.Qt.Unchecked)
This creates a list of test case name in the ListWidget. However I can't add make these items into checkboxes. item.setFlags or ItemIsUserCheckable is not recognised for list Widgets, so the two lines are commented out in the above example.
Any tips much appreciated.
Bookmarks