要删除Qt中的所有节点,可以使用以下方法:
1.获取treeview的根节点:
root = treeview.invisibleRootItem()
2.获取根节点的子节点数量:
child_count = root.childCount()
3.循环删除子节点:
for i in range(child_count):????child?=?root.child(i)
????root.removeChild(child)
完整代码如下:
root?=?treeview.invisibleRootItem() child_count?=?root.childCount() for?i?in?range(child_count):????child?=?root.child(i)
????root.removeChild(child)
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>