Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123042

QEvent::accept() works differently from QEvent::setAccepted(true)

    XMLWordPrintable

Details

    Description

      QEvent::setAccepted(bool accepted) is a virtual function. This function is reimplemented by QPointerEvent to forward the 'accepted' state to all its event points.

      The problem is that QEvent::accept() and ignore() are not virtual, and will simply toggle m_accept. This means that an event handler in Qt will function differently depending on if it chooses to accept() a mouse event, or use setAccepted(true). This is clearly wrong, and against the documentation for QEvent::accept().

      In practice this means that even if an event handler chooses to ignore a mouse event, its event point might still be left accepted. And this will stop event propagation (1), which is agains the intention of ignoring the event.

      1: QQuickDeliveryAgentPrivate::deliverPressOrReleaseEvent() checks if (event->allPointsAccepted()), and if so, stops propagation.

      Attachments

        For Gerrit Dashboard: QTBUG-123042
        # Subject Branch Project Status CR V

        Activity

          People

            richard Richard Moe Gustavsen
            richard Richard Moe Gustavsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change