diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-06 10:35:29 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-06 10:35:29 +0200 |
commit | a9210349671ce374ceadfb03443c0b5d32280acb (patch) | |
tree | c96811461a8ff284d48c079277eb3b5342bc3a24 /src/quicktemplates2 | |
parent | 8701410f8c0e179c9cca51b08fcc6491a288ee84 (diff) | |
parent | 616c430d2b7f36e70987df7b2dc97e71f0e8b589 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I859406dc779e59ee5d8e2980e04f8be28b1a69aa
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 35 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 1 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index dd0bb905..8dc70934 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -90,21 +90,7 @@ QT_BEGIN_NAMESPACE The following example demonstrates appending content to an editable combo box by reacting to the \l accepted signal. - \code - ComboBox { - editable: true - model: ListModel { - id: model - ListElement { text: "Banana" } - ListElement { text: "Apple" } - ListElement { text: "Coconut" } - } - onAccepted: { - if (find(editText) === -1) - model.append({text: editText}) - } - } - \endcode + \snippet qtquickcontrols2-combobox-accepted.qml combobox \section1 ComboBox Model Roles @@ -167,9 +153,22 @@ QT_BEGIN_NAMESPACE \qmlsignal void QtQuick.Controls::ComboBox::accepted() This signal is emitted when the \uicontrol Return or \uicontrol Enter key is pressed - on an \l editable combo box. If the confirmed string is not currently in the model, - the \l currentIndex will be set to \c -1 and the \l currentText will be updated - accordingly. + on an \l editable combo box. + + You can handle this signal in order to add the newly entered + item to the model, for example: + + \snippet qtquickcontrols2-combobox-accepted.qml combobox + + Before the signal is emitted, a check is done to see if the string + exists in the model. If it does, \l currentIndex will be set to its index, + and \l currentText to the string itself. + + After the signal has been emitted, and if the first check failed (that is, + the item did not exist), another check will be done to see if the item was + added by the signal handler. If it was, the \l currentIndex and + \l currentText are updated accordingly. Otherwise, they will be set to + \c -1 and \c "", respectively. \note If there is a \l validator set on the combo box, the signal will only be emitted if the input is in an acceptable state. diff --git a/src/quicktemplates2/qquickoverlay_p.h b/src/quicktemplates2/qquickoverlay_p.h index 0d8bccf5..1d238163 100644 --- a/src/quicktemplates2/qquickoverlay_p.h +++ b/src/quicktemplates2/qquickoverlay_p.h @@ -86,7 +86,7 @@ Q_SIGNALS: protected: void itemChange(ItemChange change, const ItemChangeData &data) override; - void geometryChanged(const QRectF &oldGeometry, const QRectF &newGeometry) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index dd7dede6..f0cf1869 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -2582,6 +2582,7 @@ void QQuickPopup::itemChange(QQuickItem::ItemChange change, const QQuickItem::It else d->popupItem->ungrabShortcut(); } + break; default: break; } |