PDA

View Full Version : QTreeView: Find nearest item to mouse pointer



squidge
31st October 2009, 18:53
I'd like to find out the item under the mouse pointer without having to left click the item first. There doesn't appear to be a function for this or am I missing something?

Lykurg
31st October 2009, 19:21
Item of what? QGraphicsScene, QListView... You can use
listWidget->itemAt(QCursor::pos());

squidge
31st October 2009, 19:52
Item of a QTreeView, as specified in the subject ;)

I didn't think I could use itemAt as it only worked for Widget views such as ListWidget rather than model views such as QTreeView, QTableView, etc ?

Lykurg
31st October 2009, 20:24
Item of a QTreeView, as specified in the subject ;)
That's a good point, and shows that I am definitely to tired...


I didn't think I could use itemAt as it only worked for Widget views such as ListWidget rather than model views such as QTreeView, QTableView, etc ?
For views it is QAbstractItemView::indexAt().