aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quickcontrols2')
-rw-r--r--examples/quickcontrols2/gallery/gallery.cpp1
-rw-r--r--examples/quickcontrols2/gallery/gallery.qml6
-rw-r--r--examples/quickcontrols2/gallery/pages/ComboBoxPage.qml25
3 files changed, 28 insertions, 4 deletions
diff --git a/examples/quickcontrols2/gallery/gallery.cpp b/examples/quickcontrols2/gallery/gallery.cpp
index 90b63cac..bfbdb49c 100644
--- a/examples/quickcontrols2/gallery/gallery.cpp
+++ b/examples/quickcontrols2/gallery/gallery.cpp
@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
QQuickStyle::setStyle(settings.value("style").toString());
QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("availableStyles", QQuickStyle::availableStyles());
engine.load(QUrl("qrc:/gallery.qml"));
if (engine.rootObjects().isEmpty())
return -1;
diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml
index 97985a6d..a8cc2629 100644
--- a/examples/quickcontrols2/gallery/gallery.qml
+++ b/examples/quickcontrols2/gallery/gallery.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.1
+import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
import QtQuick.Controls.Universal 2.1
import Qt.labs.settings 1.0
@@ -131,7 +131,7 @@ ApplicationWindow {
id: drawer
width: Math.min(window.width, window.height) / 3 * 2
height: window.height
- dragMargin: stackView.depth > 1 ? 0 : undefined
+ interactive: stackView.depth === 1
ListView {
id: listView
@@ -254,7 +254,7 @@ ApplicationWindow {
ComboBox {
id: styleBox
property int styleIndex: -1
- model: ["Default", "Material", "Universal"]
+ model: availableStyles
Component.onCompleted: {
styleIndex = find(settings.style, Qt.MatchFixedString)
if (styleIndex !== -1)
diff --git a/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml b/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml
index a52fcb67..dd06cbcb 100644
--- a/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.1
+import QtQuick.Controls 2.2
ScrollablePage {
id: page
@@ -60,5 +60,28 @@ ScrollablePage {
model: ["First", "Second", "Third"]
anchors.horizontalCenter: parent.horizontalCenter
}
+
+ Label {
+ width: parent.width
+ wrapMode: Label.Wrap
+ horizontalAlignment: Qt.AlignHCenter
+ text: "ComboBox can be made \l editable. An editable combo box auto-"
+ + "completes its text based on what is available in the model."
+ }
+
+ 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})
+ }
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
}
}