Hi,
I have an ui->tableView (set up with designer) and subclassed a QStandardItemModel to attach it, along with aQSortFilterProxyModel.

I want to make the items right-cklickable for a context menu. It nearly works - apart from a very annoying offset in the heigth that amounts to roughly half of a row's height. When I right-click an item in it's bottom half, the item below is given back.

In the dialog's constructor:
Qt Code:
  1. this->proxyModel = new QSortFilterProxyModel();
  2. proxyModel->setSourceModel(fotoImport); //foto Import is the model
  3. proxyModel->setDynamicSortFilter(true);
  4. ui->tableView->setModel(proxyModel);
  5. ui->tableView->resizeColumnsToContents();
  6. ui->tableView->resizeRowsToContents();
  7. ui->tableView->verticalHeader()->hide();
  8. ui->tableView->setSortingEnabled(true);
To copy to clipboard, switch view to plain text mode 

In the dialog's contextMenuEvent (QContextMenuEvent *e) I try this:
Qt Code:
  1. QPoint pos;
  2. pos=ui->tableView->mapFrom(this,e->pos());
  3. int row=ui->tableView->rowAt(pos.y());
  4. int column=ui->tableView->columnAt(pos.x());
  5. if (row==-1)return;
  6. if (column==-1)return;
  7. QModelIndex index=ui->tableView->indexAt(pos);
  8. QModelIndex proxyIndex;
  9. proxyIndex=this->proxyModel->mapToSource(index);
  10. qDebug()<<"map from this: "<<fotoImport->itemFromIndex(proxyIndex)->text();
To copy to clipboard, switch view to plain text mode 

It furthermore might be important that my model contains small pictures.

I've set them up this way in the model:
Qt Code:
  1. item->setData(myPixmap.scaledToHeight(50,Qt::SmoothTransformation),Qt::DecorationRole);
To copy to clipboard, switch view to plain text mode 

Instead of
pos=ui->tableView->mapFrom(this,e->pos());
I've also tried
pos=ui->tableView->mapFromParent(e->pos());
which gives equal results and
pos=ui->tableView->mapFrom(ui->tableView, e->pos());

as well as all other mapFromXXX and mapToXXX possibilities.

The columnAt() works fine.

Any idea what I am doing wrong?