Re: Misplaced Context Menu
Try
Code:
popupMenu.exec( mapToGlobal( pos ) );
Re: Misplaced Context Menu
Quote:
Originally Posted by
jrideout
Try
Code:
popupMenu.exec( mapToGlobal( pos ) );
Sorry, already tried, but no luck.
Thanx anyway.
Re: Misplaced Context Menu
Quote:
Originally Posted by
kandalf
Sorry, already tried, but no luck.
Then try the contrary :
if pos is in global coordinates :
Code:
popupMenu.exec( tablesList->mapFromGlobal(pos) );
if pos is in local coordinates :
Code:
popupMenu.exec( tablesList->mapFromGlobal(mapToGlobal(pos)) );
Hope this helps.
Re: Misplaced Context Menu
Ok guys, I couldn't make it work. I reimplemented contextMenuEvent method and now it works as it should.
My code ended up like this:
Code:
TableListWidget.h
#include <QListWidget>
{
Q_OBJECT
public:
};
TableListWidget.cpp
...
{
connect( popupMenu.addAction("&Edit Table"), SIGNAL(triggered()), this, SLOT(editActionTriggered()) );
connect( popupMenu.addAction("&Drop Table"), SIGNAL(triggered()), this, SLOT(dropActionTriggered()) );
// qWarning(tablesList->itemAt(pos)->text().toAscii());
// popupMenu.exec(pos + QPoint(tablesList->horizontalScrollBar()->value(), tablesList->verticalScrollBar()->value()));
popupMenu.exec(this->mapToGlobal(event->pos()));
}
...
Thanx everybody for the answers anyway.
Cheers!
Re: Misplaced Context Menu
Quote:
Originally Posted by
kandalf
My code ended up like this:
Code:
popupMenu.exec(this->mapToGlobal(event->pos()));
By the way, QContextMenuEvent already contains a global position of the request so it could be even:
Code:
popupMenu.exec(event->globalPos());
:)
Re: Misplaced Context Menu
Quote:
Code:
popupMenu.exec(event->globalPos());
Thanx! I saw this method in docs and I thought I tried it and did not work. But, actually, I didn't, because it DOES work.
Thanx again.
Cheers.