Results 1 to 2 of 2

Thread: Displaying QMenu at the correct position of a widget

  1. #1
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Displaying QMenu at the correct position of a widget

    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:
    Qt Code:
    1. menu->exec(ui->pushButton->pos() + QPoint(0, -80));
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by mying; 26th February 2011 at 00:51.

  2. The following user says thank you to mying for this useful post:

    zeFree (20th October 2013)

  3. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Displaying QMenu at the correct position of a widget

    Quote Originally Posted by mying View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following user says thank you to wysota for this useful post:

    zeFree (20th October 2013)

Similar Threads

  1. Replies: 1
    Last Post: 7th September 2010, 05:31
  2. Replies: 5
    Last Post: 19th March 2010, 18:13
  3. Replies: 0
    Last Post: 16th March 2010, 12:24
  4. Impossible to get correct widget background color
    By croscato in forum Qt Programming
    Replies: 4
    Last Post: 8th June 2009, 21:42
  5. Defining position for QMenu used by QPushButton
    By Ghaleon in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2009, 09:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.