PDA

View Full Version : Select QListView Item on MouseOver



renevolution
25th February 2015, 09:38
Hi,

i have a QListView containing custom Widgets and want them to be editable without first clicking in them. Currently - e.g. to check a QCheckBox - you have to select the item first before you can edit it.

So my thought is to select the item whenever the mouse enters the widget. For this i have 3 ideas but i stuck in either case.

1) Reimplement mouseMoveEvent on the QListView
- I get coordinates but how can i determine which item is underneath?

2) use eventFilter on QListView
- How to get the selected row here?

3) use eventFilter on the Widget and signal it through the delegate
- Here i'd need to be able to get at least the QModelIndex from the Item, right?

I guess option 3 is the most promising but i appreciate any help to find the solution for this.

Thanks,
René

StrikeByte
25th February 2015, 09:41
You can use indexAt ( const QPoint & p ) const to determine the QModelIndex at the mouse cursor

renevolution
25th February 2015, 11:25
Yay ... that's it ... thanks man.