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

contextMenu in Popup: mouseMoveEvent with LMB + mouseReleaseEvent sent to focus widget after context menu dismissed

    XMLWordPrintable

Details

    • macOS, Windows
    • d934fd7f54eae24ea3f719890e2c4dbbc445049d (qt/qtbase/5.14)
    • Shovelling Snow, Q1/2020 Finale

    Description

      This erroneous scenario involves dismissing a context menu that is shown from a Qt:Popup window. (i.e. two levels of Qt::Popup).

      When one dismisses a context menu shown from a Qt::Popup window by clicking away from it, the mousePressEvent is delivered to the popup, processed to close the popup, but the remaining events are delivered to the next widget with focus.

      Those remaining events are

      • 1-4 mouseMoveEvents with Qt::LeftButton held
      • a mouseReleaseEvent for Qt::LeftButton

      This is undocumented behavior inĀ https://doc.qt.io/qt-5.12/qwidget.html#events and it causes problems due to the focus widget getting drag events even though the user never started a drag event in that widget.

      See attached simple example that reproduces the problem.

      To reproduce:

      • Start the app
      • Right click in the app to bring up the custom Qt::Popup window with label "Right click to bring up context menu, then click in this window to dismiss it."
      • As the label says, right click to bring up it's context menu, then click away from it but within the bounds of the custom Qt::Popup.

      See the events logged in the MainWindow and in the console.
      It is set up to log messages for each of the mousePress, mouseMove, and mouseReleaseEvents - but only mouseMove (with LMB held) and mouseReleaseEvents are received by the PopupWindow.

      The behavior is better when the PopupWindow has the Qt::Dialog WindowType flag - in that case, the PopupWindow receives the mousePressEvent for the LMB along with the rest of the expected events above.

      Problem verified on windows - haven't tested macOS or Linux yet.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vhilshei Volker Hilsheimer
              kkyzivat Keith Kyzivat
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes