aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-02-23 16:59:39 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-17 10:30:51 +0000
commit8fb62d6dda07c495af923aa8c3d06f0c3ec7b360 (patch)
tree229e5d56780603f2a7c5cb4b9abab2797d7e86d4
parent5ca8ac68e26781e63824700edb60f095a15bd6f4 (diff)
Doc: show how to make ComboBox's popup modal/manage events outside it
Change-Id: Ib582dcf819cc674a769efcaa370ee621efcbb7aa Fixes: QTBUG-61971 Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> (cherry picked from commit 73cecf7289a8b399febe1ddec1514d2d825b087c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quickcontrols2/doc/snippets/qtquickcontrols2-combobox-popup.qml37
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp13
2 files changed, 50 insertions, 0 deletions
diff --git a/src/quickcontrols2/doc/snippets/qtquickcontrols2-combobox-popup.qml b/src/quickcontrols2/doc/snippets/qtquickcontrols2-combobox-popup.qml
new file mode 100644
index 0000000000..4aea1888be
--- /dev/null
+++ b/src/quickcontrols2/doc/snippets/qtquickcontrols2-combobox-popup.qml
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick.Controls
+
+ComboBox {
+//! [closePolicy]
+ popup.closePolicy: Popup.CloseOnEscape
+//! [closePolicy]
+//! [modal]
+ popup.modal: true
+//! [modal]
+}
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 234ba5def8..840f3d93b7 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -100,6 +100,19 @@ Q_LOGGING_CATEGORY(lcCalculateWidestTextWidth, "qt.quick.controls.combobox.calcu
\snippet qtquickcontrols2-combobox-accepted.qml combobox
+ \section1 ComboBox's Popup
+
+ By default, clicking outside of ComboBox's popup will close it, and the
+ event is propagated to items lower in the stacking order. To prevent the
+ popup from closing, set its \l {Popup::}{closePolicy}:
+
+ \snippet qtquickcontrols2-combobox-popup.qml closePolicy
+
+ To prevent event propagation, set its \l {Popup::}{modal} property to
+ \c true:
+
+ \snippet qtquickcontrols2-combobox-popup.qml modal
+
\section1 ComboBox Model Roles
ComboBox is able to visualize standard \l {qml-data-models}{data models}