QtWebEngine duplicate touch events



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



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

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



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



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



  • 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



  • 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!



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

    Thanks



  • 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 ?



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.