PDA

View Full Version : Question about selecting all items in a QListWidget



Dark_Tower
7th April 2006, 12:08
Hi all, I have a QListWidget and I have connected a button "clicked" signal to a slot where I need to select all the items in the list. This is the code that I use:

void MyPage::selectAll()
{
int n = list -> count();

if ((list -> selectedItems()).count() == n) return;

for (int i = 0; i < n; i++)
list -> setItemSelected(list -> item(i), true);
}
I want to know if there's some other way to do this more eficiently, without having to go through all the items in the list, using QListWidget::selectedItems() maybe? :confused:

Thanks.

munna
7th April 2006, 12:13
try list->selectAll()