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. How to capture mouse events in webengineview
Forum Updated to NodeBB v4.3 + New Features

How to capture mouse events in webengineview

Scheduled Pinned Locked Moved General and Desktop
webengineview
2 Posts 2 Posters 4.4k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    ejos
    wrote on last edited by ejos
    #1

    I tried to implement mouseMoveEvent in WebEngineView class.

    But after reading from the internet (https://bugreports.qt.io/browse/QTBUG-43602) got to know that QWebEngineView doesn't capture mouseEvents and it's a limitation.

    Also suggestion was given as to monitor QObject::childEvent of the QWebEngineView and install an event filter when a new child QWidget appear during page loads

    how do I do this?

    1 Reply Last reply
    0
    • cm0x4dC Offline
      cm0x4dC Offline
      cm0x4d
      wrote on last edited by
      #2

      Had the same issue. Even the topic is quite old I publish here my solution for anyone that might have this issue now.

      Note that I need to track the mouse, so I call setMouseTracking(true); in the constructor.

      class CustomWebEngineView: public QWebEngineView {
      public:
          explicit CustomWebEngineView(QWidget *parent = nullptr): QWebEngineView(parent) {
              QApplication::instance()->installEventFilter(this);
              setMouseTracking(true);
          }
      
      protected:
          bool eventFilter(QObject *object, QEvent *event) {
              if (object->parent() == this && event->type() == QEvent::MouseMove) {
                  mouseMoveEvent(static_cast<QMouseEvent *>(event));
              }
      
              return false;
          }
      };
      
      
      1 Reply Last reply
      2

      • Login

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