Delete QTreeWidgetItem in PyQt?

北慕城南 提交于 2019-12-03 02:44:13

The QTreeWidget class has an invisibleRootItem() function which allows for a somewhat neater approach:

root = tree.invisibleRootItem()
for item in tree.selectedItems():
    (item.parent() or root).removeChild(item)

PyQt4 uses sip to generate the python bindings for Qt classes, so you can delete the C++ object explicitly through the sip python API:

import sip
...
sip.delete(current)

The binding generator for PySide, shiboken, has a similar module.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!