View Full Version : Multiple selection ??

9th May 2011, 01:46

I implemented a QListwidget with a list of items in a single colum for users to select.
I wanted to start with default where there are a random number of the items being selected when the program first started.

My code is
// i is the indices for those items I want to select

When the program starts, only one item is selected. How come? I had already set the mysimpleListWidget to be multiselection.

Please help.
Thank you!

9th May 2011, 02:10
When you set the current item, you set 1 item per time. So replacing the "old current index".

Instead of using listWidget->setCurrentItem, do this:

QListWidgetItem* item = listWidget->item(i);
if (item) item->setSelected(true);