From 332011c8e6a96cd2b0c685b72f96337660f690e0 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 8 Jun 2021 15:58:18 +0200 Subject: Doc: some ComboBox functions must be used after component completion The internal QQmlDelegate model may not be ready until after componentComplete() is called. For example, the following code will print -1 for the find call, even though printing the model will show the "Hello" entry: ComboBox { id: comboBug anchors.centerIn: parent model: ["123", "BlaBla", "Hello", "Turtle"] currentIndex: { console.log("Model: " + comboBug.model) console.log("Find: " + comboBug.find("Hello")) return comboBug.find("Hello") } } Fixes: QTBUG-94257 Pick-to: 6.1 6.2 Change-Id: I6e8c2a4eb8ca7ffca0a38d2f2e914cf791d3bd2e Reviewed-by: Fabian Kosmale Reviewed-by: Paul Wicking --- src/quicktemplates2/qquickcombobox.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 71fb33c8..c94fbee8 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1659,6 +1659,8 @@ QVariant QQuickComboBox::valueAt(int index) const For an example of how to use this method, see \l {ComboBox Model Roles}. + \include qquickcombobox.qdocinc functions-after-component-completion + \sa find(), currentValue, currentIndex, valueRole */ int QQuickComboBox::indexOfValue(const QVariant &value) const @@ -1772,6 +1774,10 @@ void QQuickComboBox::setImplicitContentWidthPolicy(QQuickComboBox::ImplicitConte Returns the text for the specified \a index, or an empty string if the index is out of bounds. + \include qquickcombobox.qdocinc functions-after-component-completion + For example: + \snippet qtquickcontrols2-combobox-textat.qml textat + \sa textRole */ QString QQuickComboBox::textAt(int index) const @@ -1801,6 +1807,10 @@ QString QQuickComboBox::textAt(int index) const \value Qt.MatchContains The search term is contained in the item. \value Qt.MatchCaseSensitive The search is case sensitive. + \include qquickcombobox.qdocinc functions-after-component-completion + For example: + \snippet qtquickcontrols2-combobox-find.qml find + \sa textRole */ int QQuickComboBox::find(const QString &text, Qt::MatchFlags flags) const -- cgit v1.2.3