我在QTreeWidget中填充嵌套列表,并且需要禁用父行的选择。在
代码是:
def fillTree(self):
'''
Fill UI with list of parts
'''
roots = ['APLE', 'ORANGE', 'MANGO']
childs = ['body', 'seed', 'stern']
parent = self.treeWidget.invisibleRootItem()
for root in roots:
widgetTrim = QTreeWidgetItem()
widgetTrim.setText(0, root)
parent.addChild(widgetTrim)
for child in childs:
widgetPart = QTreeWidgetItem()
widgetPart.setText(0, child)
widgetTrim.addChild(widgetPart)
我需要避免选择“水果”项目。在
必须从item-flags中删除
Qt.ItemIsSelectable
:这些标志是一个OR'd组合
ItemFlag
值。因此,bitwise和NOT操作用于从现有的标志组合中删除ItemIsSelectable
。在相关问题 更多 >
编程相关推荐