Hi guys, I've been playing around with a context menu on a QListWidget and I can't make it work.
I have a slot connected to the customContextMenuRequested(const QPoint pos&) which creates a QMenu and opens it in "pos" (theoretically).
The thing is that I can't show the menu on the right place. It shows itself way too far from mouse, even when I debug the itemAt(pos)->text() and can see the right item is selected.
This is my code:
Qt Code:
  1. void AdminWindow::contextMenuRequested( const QPoint &pos )
  2. {
  3. if (tablesList->itemAt(pos))
  4. {
  5. QMenu popupMenu(tablesList);
  6. connect( popupMenu.addAction("&Edit Table"), SIGNAL(triggered()), this, SLOT(editActionTriggered()) );
  7. connect( popupMenu.addAction("&Drop Table"), SIGNAL(triggered()), this, SLOT(dropActionTriggered()) );
  8. // qWarning(tablesList->itemAt(pos)->text().toAscii());
  9.  
  10. popupMenu.exec(pos + QPoint(tablesList->horizontalScrollBar()->value(), tablesList->verticalScrollBar()->value()));
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 

I tried adding values from scrollbars as I saw in this forum, but no luck.
I also tried with mapToParent() and mapToGlobal(), same results.
Any ideas?

Thanks a lot in advance.