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. Adding Hotkeys
Forum Update on Monday, May 27th 2025

Adding Hotkeys

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.0k 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.
  • N Offline
    N Offline
    nicky j
    wrote on 12 Jun 2013, 23:15 last edited by
    #1

    Hey!
    So I am building my browser and I was wondering if there was a way that I could add hotkeys. For example option/alt would highlight the searchbar, or command-f makes the window fullscreen.
    I have the fullscreen code right here:
    @void MainWindow::on_actionFullscreen_triggered()
    {
    setWindowState(Qt::WindowFullScreen);
    }
    @
    Is there a way to add hotkey functionality to this code? Thanks!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on 13 Jun 2013, 03:44 last edited by
      #2

      Yes, you can use QAction or QShortcut.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on 13 Jun 2013, 04:28 last edited by
        #3

        As 1+1=2 says you can set shortcut to action.
        @actionFullscreen - >setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F));@

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nicky j
          wrote on 14 Jun 2013, 22:02 last edited by
          #4

          Ok, thank you both!
          Haha its a lot simpler then I thought it would be!
          probably a n00b question, but thanks all the same!

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nicky j
            wrote on 14 Jun 2013, 22:12 last edited by
            #5

            Oh yeah, what are the arrow keys and what is Key_Forward?

            1 Reply Last reply
            0

            1/5

            12 Jun 2013, 23:15

            • Login

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