Results 1 to 2 of 2

Thread: Select first QMenu from QMenuBar using ALT key

  1. #1
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Select first QMenu from QMenuBar using ALT key

    Hello everyone!

    I'm having the folowing problem: I want the first QMenu from QMenuBar to be selected when I press the ALT key.
    I saw that if I create a new project and I create some QMenu objects and add them to the QMenuBar I get the desired behavior, but I'm working on a big project and I can't get this to work. Did anybody had this problem, has an idea what might be causing this?

    I've tried to change the NativeMenuBar property but that didn't help.

    Thank you!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Select first QMenu from QMenuBar using ALT key

    As the QMenuBar documentation says:

    The ampersand in the menu item's text sets Alt+F as a shortcut for this menu.

    fileMenu = menuBar()->addMenu(tr("&File"));
    The first menu is selected when you press ALT because Qt doesn't know what the second key ("F") is going to be until you press it. It doesn't actually do anything except highlight it.

    If the menus in your existing app are not defined with the "&" shortcuts, then the ALT key has nothing to select and you don't get this behavior. So you'll need to go back and edit either the UI files or the C++ code to insert the "&" where you want them.

Similar Threads

  1. Highlight the Qmenu/QmenuBar in Qt
    By rohitkk in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2014, 11:37
  2. QMenuBar and QMenu colors
    By Raadush in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2012, 11:19
  3. how to add widget to QMenubar
    By Prashant Moglaikar in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2011, 11:04
  4. QMenuBar and QMenu
    By thedoctor in forum Qt Programming
    Replies: 0
    Last Post: 21st December 2009, 21:01
  5. Hide Qmenubar
    By user_mail07 in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2008, 22:16

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.