Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get selected listitem index in Qt

I am having a QListView which contains some items. Now I want to get the index of selected item, i.e. if I select 5th element I should get 5. How I can get this?

like image 597
Naruto Avatar asked Apr 16 '10 06:04

Naruto


1 Answers

In every view in Qt, you have the following method :

QItemSelectionModel * QAbstractItemView::selectionModel () const

Basically, it returns a model on which you can perform actions, like getting selected indexes...

Have a look here : QItemSelectionModel

You'll find plenty of methods to help you get your index(es).

Hope it helps!

like image 134
Andy M Avatar answered Oct 06 '22 20:10

Andy M