Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get multiple selected Items from a QListwidget

How to get multiple selected Items from a QListwidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JohnSRV
    wrote on last edited by
    #1

    Hello everyone,

    in my GUI I have a QListwidget called TargetList.
    09eff2de-3e0c-4fde-bb35-45e24bb02133-image.png

    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 !

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      @JohnSRV said in How to get multiple selected Items from a QListwidget:

      connect(ui->TargetList, SIGNAL(itemSelectionChange()), this, SLOT(SelectedTargets()));

      itemSelectionChanged()
      And, use QListWidget::selectedItems() to get all selected items.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved