You are not logged in.

1

Tuesday, March 24th 2009, 5:36pm

How to iterate among the QListWidgetItems of a QListWidget ?

I have an horizontal QListView that shows multiple thumbnails.
For different reasons, i must be able to move the selection from the currently selected item to the one immediately to his left or right.

In other words, i must find the previous or next QListViewItem in relation to the currently selected one.

Source code

1
ui->listWidget->currentItem()->nextItem()->selected(true);	// This of course, doesn't work !!!!


Thanks !

2

Tuesday, March 24th 2009, 5:48pm

Source code

1
2
3
foreach(QListWidgetItem *selectedItem, ui->listWidget->selectedItems()) {
    // do something with selectedItem
}
Mandriva Linux release 2009.0 (Official) for i586
Kernel 2.6.27.10-desktop-1mnb on a Dual-processor i686

3

Tuesday, March 24th 2009, 8:01pm

Source code

1
2
3
foreach(QListWidgetItem *selectedItem, ui->listWidget->selectedItems()) {
    // do something with selectedItem
}
I am working in single selection mode !

I do not which to iterate among the selected items...
I want to iterate amont the items in the list itself.

4

Tuesday, March 24th 2009, 8:41pm

Source code

1
2
3
4
// select next
ui->listWidget->setCurrentRow(ui->listWidget->currentRow() + 1, QItemSelectionModel::SelectCurrent);
// select previous
ui->listWidget->setCurrentRow(ui->listWidget->currentRow() - 1, QItemSelectionModel::SelectCurrent);
Mandriva Linux release 2009.0 (Official) for i586
Kernel 2.6.27.10-desktop-1mnb on a Dual-processor i686