Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.10.1
-
None
-
-
e4ef0f03e (dev)
Description
When creating a sub-window in Qt Quick with the Qt::Popup flag set, it does not close when the user clicks on a point outside the window.
An equivalent implementation in Qt Widgets works correctly - the popup behaves exactly like a typical right-click context menu and disappears if the user clicks on any point of the screen which is not in the popup, no matter if the click was in the parent window or in a different application or even the desktop.
Possibly, QQuickItem::grabMouse() is not called correctly?!
See the following code snippets to understand the issue (tested on Linux X11).
Qt Quick example:
The popup won't disappear if the user clicks outside it. A kind of workaround is to listen to the onActiveChanged event and close the popup if the window lost its active state. However, this covers only the case when the user clicks on a different window. If you click on the parent window, the popup won't close.
import QtQuick 2.2 import QtQuick.Window 2.1 Window { id: mainWindow width: 200 height: 200 Window { id: dropdown y: mainWindow.y + 50 visible: true x: mainWindow.x + 50 height: 200 width: 200 flags: Qt.Popup color: 'green' Text { text: "I should disappear when you click anywhere outside me" wrapMode: Text.WrapAnywhere anchors.left: parent.left anchors.right: parent.right anchors.margins: 5 color: "white" } } }
Qt Widgets example:
The popup is closed when the user clicks on any point of the screen which is not inside the popup (this is how it should be in Qt Quick as well).
#include <QWindow> #include <QApplication> #include <QMainWindow> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow qWin; qWin.setFixedSize(640, 400); qWin.show(); QWidget qPopup(&qWin, Qt::Popup); qPopup.setFixedSize(320, 200); qPopup.show(); return app.exec(); }
Attachments
Issue Links
- depends on
-
QTBUG-68080 we need to move popup event forwarding logic from QWidgetWindow::handleMouseEvent() to QGuiApplication
- Closed
- duplicates
-
QTBUG-33481 Clicking outside a Window whose flags are Qt.Popup should close that window
- Open
-
QTBUG-45689 Auto dismiss Popup windows are hard to implement
- Open
-
QTBUG-36903 Popup menu don't disappear when clicked on qml region (Mac OS)
- Closed
- relates to
-
QTBUG-35261 When QWindowContainer is used on a widget and a Popup window is open, left-clicking QWindow area won't close the popup window.
- Reported
-
QTBUG-45079 xcb: XI2: menus and combobox popups work badly on touchscreens
- Reported
-
QTBUG-30265 When QWindowContainer is used on a widget and a Popup window is open, left-clicking outside of popup doesn't get replayed.
- Open
-
QTBUG-31224 Qt::Popup window flag behave incorrect
- Open
-
QTBUG-50051 Mouse release events missing when closing popup window
- Open
-
QTBUG-45315 MenuBar top level menus are not closed on click after being opened
- Closed
-
QTBUG-30312 Clicking Mac title bar in other window doesn't close popup
- Closed
-
QTBUG-69790 Refactor QtQuick Window in Qt 6
- Reported
-
QTBUG-81605 Near impossible to rotate ApplicationWindow's contents 90 degrees (switch landscape -> portrait)
- Reported
Gerrit Reviews
For Gerrit Dashboard: QTBUG-69777 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
565090,3 | WIP Move responsibility to close popups when clicking outside to QtGui | dev | qt/qtbase | Status: NEW | -2 | -1 |