How to get multiple selected Items from a QListwidget
-
Hello everyone,
in my GUI I have a QListwidget called TargetList.
After starting the search I get a List of the available Devices. Now the User can choose to which Devices he wants to connet. Till now I had no problem with only one Target.
But if the User selects multiple Targets I need a List of the Devices he selected so I can adapt the actions to be done for multiple Devices. The Question is how to get that List? I enabled multiple Selections in Qt Creator.
I tried the following Code
connect(ui->TargetList, SIGNAL(itemSelectionChange()), this, SLOT(SelectedTargets()));
Whenever the Selection changes the Signal fires and the Slot i have the following Lines:
QStringList ListSelected; QString selected = ui->TargetList->currentItem()->text(); printf(selected.toStdString().c_str()); ListSelected.append(selected);
This should construct the needed List. But when Running i get the error that there's no such Signal as itemselectionchanged().
Thanks !
-
@JohnSRV said in How to get multiple selected Items from a QListwidget:
connect(ui->TargetList, SIGNAL(itemSelectionChange()), this, SLOT(SelectedTargets()));
itemSelectionChange
d
()
And, useQListWidget::selectedItems()
to get all selected items.