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. QtWebEngine duplicate touch events

QtWebEngine duplicate touch events

Scheduled Pinned Locked Moved QtWebEngine
9 Posts 3 Posters 3.9k 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.
  • A Offline
    A Offline
    ageblade
    wrote on last edited by
    #1

    Hi,
    I have a problem with touch events using a QWebEngineView within my QApplication.
    When i click on a button in my web page it is double clicked by Qt for some reason, when i open the same page in Chrome this behavior is not happening.

    Did someone else bumped into this ? Is there any known solution ?

    Thanks, Idan

    Update:

    Tried the attributes:
    WA_AcceptTouchEvents
    WA_TouchPadAcceptSingleTouchEvents
    AA_SynthesizeMouseForUnhandledTouchEvents
    AA_SynthesizeTouchForUnhandledMouseEvents

    But none of them works for this issue.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gladiatorchirag
      wrote on last edited by
      #2

      I am facing the same issue. Tried everything but no success yet.

      Related bug:
      https://bugreports.qt.io/browse/QTBUG-39814

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ageblade
        wrote on last edited by
        #3

        Hi,
        I managed to overcome this bug using a QEventFilter and filtering mouse events on the widget and it's children. I will post the code soon.

        However if you need both your mouse events and touch events handled this is not the solution for you, but maybe a good start.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gladiatorchirag
          wrote on last edited by
          #4

          Thanks "ageblade". Kindly post the code soon. This has become a bottleneck for me....

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ageblade
            wrote on last edited by
            #5

            Hi, sorry for the delay.. but here it is!

            This is the code initializing the view in the main function:

            @
            QWebEngineView view;
            view.load(url);
            view.show();

            for (int i = 0; i < view.children().size(); i++)
            {
            QObject *child = view.children().at(i);
            child->installEventFilter(new QMouseEventFilter);
            }
            @

            and QMouseEventFilter.h is :
            @
            #include <QtCore/QEvent>
            #include <QtCore/QObject>

            class QMouseEventFilter : public QObject
            {
            Q_OBJECT
            public:

            QMouseEventFilter(QObject *parent = 0) : QObject(parent)
            {
            }

            protected:

            bool eventFilter(QObject * p_obj, QEvent * p_event)
            {
            if (p_event->type() == QEvent::MouseButtonDblClick ||
            p_event->type() == QEvent::MouseButtonPress ||
            p_event->type() == QEvent::MouseButtonRelease ||
            p_event->type() == QEvent::Wheel)
            {
            p_event->ignore();
            return true;
            }
            return false;
            }
            };
            @

            Enjoy

            1 Reply Last reply
            1
            • G Offline
              G Offline
              gladiatorchirag
              wrote on last edited by
              #6

              Hi,
              Thanks for your prompt reply, really helped me a lot.
              I Updated your code a little bit and now both mouse and touch interaction are going on perfectly fine. Hope you and everyone else can also benefit from it.

              @bool eventFilter(QObject * p_obj, QEvent * p_event)
              {
              if (p_event->type() == QEvent::MouseButtonDblClick ||
              p_event->type() == QEvent::MouseButtonPress ||
              p_event->type() == QEvent::MouseButtonRelease ||
              p_event->type() == QEvent::Wheel)
              {
              QMouseEvent* pMouseEvent = dynamic_cast<QMouseEvent*>(p_event);
              if ((pMouseEvent != NULL) && (pMouseEvent->source() == Qt::MouseEventSource::MouseEventSynthesizedBySystem))
              {
              p_event->ignore();
              return true;
              }
              }
              return false;
              }@

              Cheers!

              1 Reply Last reply
              1
              • A Offline
                A Offline
                ageblade
                wrote on last edited by
                #7

                Hi again,
                Can you please check this issue in Qt 5.4.1 ?
                Maybe it got fixed in the new patch release

                Thanks

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ageblade
                  wrote on last edited by
                  #8

                  Hello fellow historians,

                  I checked this issue with Qt 5.5.1 and it is still seems to be an issue.
                  Did anyone got to fix this in more elegant manner ?

                  1 Reply Last reply
                  0
                  • BambiB Offline
                    BambiB Offline
                    Bambi
                    wrote on last edited by
                    #9

                    Am suffering from the same issue.. still havent checked if it changed in 5.6

                    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