[SOLVED] How to select item 3 of listwidget in 1 line?
General and Desktop
5
Posts
2
Posters
1.6k
Views
1
Watching
-
wrote on 7 Sept 2012, 20:30 last edited by
i just want to select item 3 of listwidget and it seems that
@ui->listwidget->setCurrentItem(3);@won't work.
I know a way to do it if i create a list of the items but it is about in 6 lines just to select an item.. -
wrote on 7 Sept 2012, 20:33 last edited by
You might try via the selectionModel().
-
wrote on 7 Sept 2012, 20:43 last edited by
could you please be a little more detailed? at list one link to know where to look up...?
-
wrote on 7 Sept 2012, 20:45 last edited by
Check [[doc:QAbstractItemModel]] for the selectionModel() method, and [[doc:QItemSelectionModel]] for the documentation of the selection model itself.
-
wrote on 15 Sept 2012, 09:05 last edited by
Well i prefered doing it this way as 1 row has 1 item:
@
ui->listWidget_2->setFocus();
ui->listWidget_2->setCurrentRow(2);@:)