Get checked items of listWidget
-
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??
-
- you can iterate through QListWidget
- you can create slot to handle signals of widgets are changing.
-
If I iterate, which is the condition to know is checked?
-
have you looked at http://qt-project.org/doc/qt-5/qlistwidgetitem.html#checkState ?