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

QWebEngineView with Qt::NoContextMenu policy fails to defer contextmenu event to parent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.0 Beta 4
    • 5.9.1
    • WebEngine
    • None
    • cc6a4199225f034075751580fd5fd816cbfee6ea

    Description

      If a widget has Qt::NoContextMenu set, then

      the widget does not feature a context menu, context menu handling is deferred to the widget's parent.

      From https://doc.qt.io/qt-5/qt.html#ContextMenuPolicy-enum

      Just, QWebEngineView does not follow that specification, instead it just swallows the event, so the context menu on the parent widget is not instead invoked.

      Reason seems to be that bool QWebEngineView::event(QEvent *ev) has an implementation which always accepts events of type QEvent::ContextMenu, so no deferring to the parent ever happens, including the case of Qt::NoContextMenu.
      See http://code.qt.io/cgit/qt/qtwebengine.git/tree/src/webenginewidgets/api/qwebengineview.cpp#n317

      A fix would be to make that method follow instead the behaviour of bool QWidget::event(QEvent *event) and only accept the event in case of matching policies, and ignore in case of others, incl. Qt::NoContextMenu.

      See http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/kernel/qwidget.cpp#n8981

      Attachments

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

        Activity

          People

            fokinv Valentin Fokin
            kossebau Friedrich W. H. Kossebau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes