Results 1 to 4 of 4

Thread: how to set user defined shortcut keys in menu

  1. #1
    Join Date
    Mar 2011
    Location
    delhi
    Posts
    45
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation how to set user defined shortcut keys in menu

    hi all please tell me how to set user defined shortcut keys in menu like(CTRL+ALT+P).




    thanks with regards:
    gauravg

  2. #2
    Join Date
    Dec 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to set user defined shortcut keys in menu

    Hi Gauravg,

    the way I do it:

    1. Create a QAction (QAction *action = new QAction(tr("New"))
    2. Set the shortcut for the created QAction. (action->setShortcut("Ctrl+N"))
    3. Add the QAction to your menu (menu->addAction(action))

    Best regards

    Ralf

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to set user defined shortcut keys in menu

    Do you mean that it's the user that should be able to set the shortcuts to what he wants?

  4. #4
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: how to set user defined shortcut keys in menu

    If your want your app to give user possibility to set shortcuts, then implement shortcut editor inside your app and bind shortcuts to actions in runtime as in Ralf's sample.
    Oleg Shparber

Similar Threads

  1. Shortcut keys??
    By Zingam in forum Qt Quick
    Replies: 1
    Last Post: 20th July 2011, 08:53
  2. How to get user-defined message?
    By ponponfish in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2011, 16:19
  3. Shortcut, some keys won't work
    By smoon in forum Qt Programming
    Replies: 0
    Last Post: 27th February 2011, 11:19
  4. Assign shortcut keys to buttons
    By mecrazycoder in forum Newbie
    Replies: 0
    Last Post: 7th January 2011, 22:42
  5. User Defined Signal?
    By rajeshs in forum Newbie
    Replies: 2
    Last Post: 18th December 2007, 11:42

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.