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. Get checked items of listWidget

Get checked items of listWidget

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.5k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rcaji
    wrote on last edited by
    #1

    Hi,

    Anyone knows how to get the checked items of my listWidget?

    code:

    @QDir dir("/my/dir");
    QStringlist filter;
    QString name;

    filter << *jpeg;
    dir.setFilter(QDir::System | QDir::Files);
    dir.setSorting(QDir::Unsorted);

    foreach(QFileInfo dirItem, dir.entryInfoList(filter))
    

    {
    if(dirItem.isFile())
    {
    name = dirItem.absoluteFilePath();
    QListWidgetItem *item = new QListWidgetItem;
    item->setCheckState(Qt::Unchecked);
    item->setData(Qt::DisplayRole, name);
    ui->listWidget->addItem(item);
    }
    }
    @

    When I push a button, how I know which item is checked??

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MrMNight
      wrote on last edited by
      #2
      1. you can iterate through QListWidget
      2. you can create slot to handle signals of widgets are changing.
      1 Reply Last reply
      0
      • R Offline
        R Offline
        rcaji
        wrote on last edited by
        #3

        If I iterate, which is the condition to know is checked?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MrMNight
          wrote on last edited by
          #4

          have you looked at http://qt-project.org/doc/qt-5/qlistwidgetitem.html#checkState ?

          1 Reply Last reply
          0

          • Login

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