Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Adding Hotkeys

    General and Desktop
    3
    5
    3849
    Loading More Posts
    • 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
      nicky j last edited by

      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 Reply Quote 0
      • D
        dbzhang800 last edited by

        Yes, you can use QAction or QShortcut.

        1 Reply Last reply Reply Quote 0
        • Q
          qxoz last edited by

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

          1 Reply Last reply Reply Quote 0
          • N
            nicky j last edited by

            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 Reply Quote 0
            • N
              nicky j last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post