PDA

View Full Version : Displaying QMenu at the correct position of a widget



mying
26th February 2011, 00:51
I'am trying to have a a QMenu to popup after a user clicks on a QPushButton (on Symbian). Right now it's being called like this:


menu->exec(ui->pushButton->pos() + QPoint(0, -80));

At first that works fine. But when the phone switches to Landscape mode, the left side of the menu would not line up with the left side of the button. If you switch it back to Portrait mode again, the menu cannot even be seen anymore. How could I execute the QMenu at the 'correct' position?

Added after 32 minutes:

Well, never mind. moving and then showing the QMenu works. In certain cases it needs to mapToGlobal() though. yay :)

wysota
27th February 2011, 08:15
Well, never mind. moving and then showing the QMenu works. In certain cases it needs to mapToGlobal() though. yay :)
You always need mapToGlobal() because QMenu::exec() accepts a global coordinate. As explained in the docs, by the way.