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

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 29 Aug 2015, 22:31 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.

    P 1 Reply Last reply 30 Aug 2015, 04:01
    0
    • O ospf
      29 Aug 2015, 22:31

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

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 30 Aug 2015, 04:01 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 31 Aug 2015, 00:00 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".

        P 1 Reply Last reply 31 Aug 2015, 05:12
        0
        • O ospf
          31 Aug 2015, 00:00

          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".

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 31 Aug 2015, 05:12 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 3 Sept 2015, 00:48 last edited by
            #5

            @p3c0 That worked, thanks for your help.

            1 Reply Last reply
            0

            1/5

            29 Aug 2015, 22:31

            • 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