[Qt-interest] QTableView, wrong cell index by position

Josinei Silva josinei_listas at yahoo.com.br
Wed Jan 21 06:47:24 CET 2009


Hi,

I need to show a tooltip for one column at a QTableView subclass. I.m using 
eventFilter to get ToolTip event and show the tooltip when the cursor is over 
the column i need.

But when i'm using these lines to get column index:

  QHelpEvent *HelpEvent = static_cast<QHelpEvent *>(Event);
  QModelIndex Index = tbvTable->indexAt( HelpEvent->pos() );

The index position doesn't match with index position of the column where the 
cursor is.
I got row 0 when the cursor is over the horizontal header and at the last 
line, i got row -1, column -1.
I got column 0 when the cursor is over the vertical header and at the last 
column i got row -1, column -1.

The row is always wrong, at row 0, i got row 1 and so on.
The column changes at the middle of the column, not at the borders.

It looks like QTableView is not considering Horizontal Header and Vertical 
Header when calculating the index of a postion.

I should compensate horizontal header and vertical header manualy or there's a 
way to tell QTableView to do it?

Thanks

Josinei R. L. Silva



More information about the Qt-interest-old mailing list