[Development] Erroneous Qt TouchBegin event to QGraphicsView ?

Patrick Stinson patrickkidd at gmail.com
Thu Aug 3 04:54:51 CEST 2017


Hi there!

I am seeing a QEvent::TouchBegin being sent to the QGraphicsView viewport (on Mac) when moving the mouse into or out of the view with no buttons pressed. I noticed this because if a QLineEdit somewhere else on the window, and then I move the mouse over the view, the line edit loses focus within the last line in the following code block in Application::notify, where “widget” is the QGraphicsView viewport.

At other times this same block is called (indicating a TouchBegin event) when I simply move the mouse outside the view again.

What gives? The stack trace doesn’t include the generation of the touch event so I can’t infer the conceptual policy here. Seems like line edit should at least retain focus when not clicking or dragging anywhere.

Thank you!

    case QEvent::TouchBegin:
    // Note: TouchUpdate and TouchEnd events are never propagated
    {
        QWidget *widget = static_cast<QWidget *>(receiver);
        QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
        bool eventAccepted = touchEvent->isAccepted();
        bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);

        if (acceptTouchEvents && e->spontaneous()) {
            const QPoint localPos = touchEvent->touchPoints()[0].pos().toPoint();
            QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, e, localPos);
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170802/8ab9e629/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1403 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170802/8ab9e629/attachment.bin>


More information about the Development mailing list