Get multiselected Indexes of a QListwidget
-
Hi,
I have a QListWidget with 8 Items, that the user can multi select.
I want to store the selected indexes into a variable.I need the variables in this format:
@
MyIndexes[8] = {0,1,2,3,4} // with getSelectedIndexes
@in the other way I want to load my stored indexes in to the widget (setSelectedIndexes)
@ui->Mylist = (MyIndexes);
@Can someone please help me?
I tried but I failed.BR
Sam -
Did you try this ?
@QListWidget wid = new QListWidget;
QList<QListWidgetItem> list = wid->selectedItems();
//Iterate over each item
// Call
QListWidgetItem->setSelected(true)@ -
Here is what I said and code snippet as well.
@ listWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
qDebug() << "Selected items =" << list1.count();
for(int i=0;i<list1.count();i++){
//qDebug() << "I =" << i << endl;
QListWidgetItem it = (QListWidgetItem)list1.at(i);
qDebug() << " Value ="<<it->text();
it->setSelected(true);
}
@