Qt Forum

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

    QtWebEngine duplicate touch events

    QtWebEngine
    3
    9
    3171
    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.
    • A
      ageblade last edited by

      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 Reply Quote 0
      • G
        gladiatorchirag last edited by

        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 Reply Quote 0
        • A
          ageblade last edited by

          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 Reply Quote 0
          • G
            gladiatorchirag last edited by

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

            1 Reply Last reply Reply Quote 0
            • A
              ageblade last edited by

              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 Reply Quote 1
              • G
                gladiatorchirag last edited by

                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 Reply Quote 1
                • A
                  ageblade last edited by

                  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 Reply Quote 0
                  • A
                    ageblade last edited by

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

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

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