PDA

View Full Version : PyQt remove the current QTreeWidgetItem



koenux
10th January 2009, 22:25
Hello,

I have in my PyQT4 application a QTreeWidget. But I can't find a function to remove the current QTreeWidgetItem. I've found the function QTreeWidget::removeItemWidget ( QTreeWidgetItem * item, int column ), but when I try this function, nothing seems to happening. I guess removeItemWidget is not to remove a total treeWidgetItem?


def contextActionRemove(self):
item = self.parent.ui.tree_playlist.currentItem();
self.parent.ui.tree_playlist.removeItemWidget(item , 0)

How can I remove a QTreeWidgetItem?

Thanks a lot!

jpn
10th January 2009, 22:59
"Item widgets" are widgets laid on top of items. It is possible to insert for example a QPushButton on top of a single QTreeWidgetItem. Anyway, in C++ one would simply delete the QTreeWidgetItem. There's also QTreeWidget::takeTopLevelItem() and QTreeWidgetItem::takeChild().

koenux
10th January 2009, 23:08
Thanks! QTreeWidget::takeTopLevelItem() works. Stupid that I didn't try takeTopLevelItem before...