PDA

View Full Version : Innacurate QModelIndex computations



AlexSudnik
18th February 2011, 11:15
So the thing is that i need to call a menu on a per-item basis, and one of the ways i've found so far was this:

Set table's parent context menu policy to Qt::CustomContextMenu
Connect customContextMenuRequested(const QPoint&) signal with a custom slot
Get the underlying item index via the
QModelIndex QAbstractItemView::indexAt ( const QPoint & point )

But somehow the index i get doesn't always belong to the item i clicked on. I mean,if i right-click in the center of an item:no problems.But as i move closer to the upper or lower edget of it...things start getting worse.

So maybe there are some options available or smth.Any tips are greatly appreciated!

wysota
18th February 2011, 12:28
You are mixing two coordinate systems - that of the view and that of its viewport.