Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]shortcut

[solved]shortcut

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 902 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yakine
    wrote on last edited by
    #1

    I have created a GUI using Qt Creator. That is by drag and drop the widgets. Now I want to assign shortcut keys a the button. Can anyone here please let me know how to do that? Thank you in advance

    IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on last edited by
      #2

      Hi, you can do it in the Creator by editing the property "shortcut" of the pushButton (e.g. press Ctrl and C in that property field)

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        You can put an ampersand in the buttons text eg.
        @
        auto button = new QPushButton("Hit &me!", parent);
        @
        You can also do that in the designer's properties. It will assign Alt+m to that button (whatever letter after &).

        A more general way is to create a QAction.
        Connect button clicked() signal to the action's trigger() slot.
        Set a "shortcut":http://qt-project.org/doc/qt-5/qaction.html#shortcut-prop.
        Set global (or whatever you want) shortcut "context":http://qt-project.org/doc/qt-5/qaction.html#shortcutContext-prop.
        Connect to the triggered() signal of the action and do your work there.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yakine
          wrote on last edited by
          #4

          Hi Clochydd &Chris Kawa

          thank you both it's work for me

          IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved