Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Keyboard shortcuts for QWebEngineView navigation
Forum Update on Monday, May 27th 2025

Keyboard shortcuts for QWebEngineView navigation

Scheduled Pinned Locked Moved QtWebEngine
qwebengineviewc++
5 Posts 2 Posters 2.5k 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.
  • O Offline
    O Offline
    ospf
    wrote on last edited by
    #1

    I have tried QKeySequence, QAction and QKeyEvent among other things and I can't get it to work. Here is the code.

    p3c0P 1 Reply Last reply
    0
    • O ospf

      I have tried QKeySequence, QAction and QKeyEvent among other things and I can't get it to work. Here is the code.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #2

      Hi @ospf,
      There are 2 ways to do it:

      • Using a QMenu and adding QAction to it using addAction and then setShortcut to it. I see you have already tried it but it works. The prerequisite is it needs a QMenu.
        For Eg. Check this Browser example especially this class and browse to setupMenu() method
      • Use QShortcut and connect its activated signal to a slot which will get executed on trigger.
        Eg.
      QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+r"), this);
      QObject::connect(shortcut, SIGNAL(activated()), view, SLOT(reload()));
      //view = QWebEngineView and reload() = its slot.
      

      Edit: added example link.

      157

      1 Reply Last reply
      1
      • O Offline
        O Offline
        ospf
        wrote on last edited by
        #3

        Great thanks, how do I add it to my code? When I try to add the QShortcut answer to the main function I get "invalid use of 'this' in a non-member function".

        p3c0P 1 Reply Last reply
        0
        • O ospf

          Great thanks, how do I add it to my code? When I try to add the QShortcut answer to the main function I get "invalid use of 'this' in a non-member function".

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @ospf The second parameter expects a QWidget so this should point to a QWidget but in your case it is not. Try passing your QWebEngineView's object.

          157

          1 Reply Last reply
          1
          • O Offline
            O Offline
            ospf
            wrote on last edited by
            #5

            @p3c0 That worked, thanks for your help.

            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