aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-15 15:32:54 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-17 13:54:11 +0000
commit4ac9cce0879ea96a79511dbadd150dbe61db945c (patch)
tree52b62df7f9b22fb7275aee5951d85cd7886c7808 /examples
parent7c73d40b8215e8947b123dd006e7c62e93d396fa (diff)
Gallery: use QQuickStyle to set the style in C++
This consequently fixes Gallery to respect the -style command line argument and the QT_LABS_CONTROLS_STYLE environment variable. Change-Id: I0e92d1a51e539026a66b821ac425348c87a922c3 Task-number: QTBUG-50787 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/controls/gallery/gallery.cpp7
-rw-r--r--examples/controls/gallery/gallery.pro2
-rw-r--r--examples/controls/gallery/gallery.qml2
3 files changed, 8 insertions, 3 deletions
diff --git a/examples/controls/gallery/gallery.cpp b/examples/controls/gallery/gallery.cpp
index 778ecbc2..90b63cac 100644
--- a/examples/controls/gallery/gallery.cpp
+++ b/examples/controls/gallery/gallery.cpp
@@ -42,6 +42,7 @@
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QSettings>
+#include <QQuickStyle>
int main(int argc, char *argv[])
{
@@ -52,7 +53,11 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QSettings settings;
- qputenv("QT_LABS_CONTROLS_STYLE", settings.value("style").toByteArray());
+ QString style = QQuickStyle::name();
+ if (!style.isEmpty())
+ settings.setValue("style", style);
+ else
+ QQuickStyle::setStyle(settings.value("style").toString());
QQmlApplicationEngine engine;
engine.load(QUrl("qrc:/gallery.qml"));
diff --git a/examples/controls/gallery/gallery.pro b/examples/controls/gallery/gallery.pro
index c31529b7..8f3e7f86 100644
--- a/examples/controls/gallery/gallery.pro
+++ b/examples/controls/gallery/gallery.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = gallery
-QT += quick
+QT += quick labscontrols
SOURCES += \
gallery.cpp
diff --git a/examples/controls/gallery/gallery.qml b/examples/controls/gallery/gallery.qml
index 90f4b347..0c44cce3 100644
--- a/examples/controls/gallery/gallery.qml
+++ b/examples/controls/gallery/gallery.qml
@@ -241,7 +241,7 @@ ApplicationWindow {
property int styleIndex: -1
model: ["Default", "Material", "Universal"]
Component.onCompleted: {
- styleIndex = find(settings.style)
+ styleIndex = find(settings.style, Qt.MatchFixedString)
if (styleIndex !== -1)
currentIndex = styleIndex
}