laurent
laurent

Reputation: 90776

How to get the selected item delegate in a QListView

I want to implement drag and drop on my QListView, so I would like to get the selected item delegate. How can I do that?

Upvotes: 2

Views: 2197

Answers (2)

rob
rob

Reputation: 116

I'm not sure if this will help You, but You can use this functions:

void QListView::currentChanged ( const QModelIndex & current, const QModelIndex & previous ) [virtual protected]

and

void QAbstractItemView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) [virtual protected slot]

and refer to Qt QAbstractItemView class documentation

greetings Robert

Upvotes: 0

Exa
Exa

Reputation: 4110

I haven't tested this for myself, but this is what I found out by reading the documentation.

QListView has a QList<QModelIndex> which contains the selected items. You can access this list using QListView::selectedIndexes().

Then you can call QAbstractItemView::itemDelegate( const QModelIndex& index ) for your selected index. This function returns a QAbstractItemDelegate*.

Upvotes: 3

Related Questions