View Full Version : Howto remove row from QListWidget
pospiech
29th July 2008, 15:06
I tried the following to remove a row from the list
int row = listWidgetVideo->currentRow();
listWidgetVideo->removeItemWidget(listWidgetVideo->item(row));
but nothing happens.
How do I do this correct?
EDIT:
seems to be
listWidgetVideo->takeItem(row);
Notice that takeItem() takes the item away from the tree and returns it. The item is NOT deleted. You are responsible for deleting it yourself (calling takeItem() without handling the return value will lead to a memory leak). One can also fairly well just directly delete an item and the item will be properly removed from the list. The takeItem() method was mainly provided for cases when you need to take an item temporarily away from the list but keep it alive so that it can be restored later.
pospiech
29th July 2008, 19:24
Notice that takeItem() takes the item away from the tree and returns it. The item is NOT deleted. You are responsible for deleting it yourself (calling takeItem() without handling the return value will lead to a memory leak). One can also fairly well just directly delete an item and the item will be properly removed from the list. The takeItem() method was mainly provided for cases when you need to take an item temporarily away from the list but keep it alive so that it can be restored later.
From all you say I only understand two things which leave me with even more questions.
1. I do not delete the item with takeItem(). But how do I delete it?
2. Real deletion without takeItem() works different. But how?
wysota
29th July 2008, 19:32
I do not delete the item with takeItem(). But how do I delete it?
By calling delete on it. And you don't have to take it out of the list before you do that.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.