From 9df3d850a1cf47d82ed5e57d0fa8bfe74b4f3c9e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 May 2015 15:54:37 +0200 Subject: [PATCH] Qt Quick Control Application: Optional QtWidget dependency Let the user chose whether "native styling" via QWidgets/QApplication should be enabled or not. Change-Id: I5eaa7b3a94d5361e62ebce61ff6b7b9216e15b80 Reviewed-by: Thomas Hartmann --- .../projects/qmake/qtquickcontrolsapplication/app.pro | 4 ++++ .../qmake/qtquickcontrolsapplication/main.cpp | 6 +++++- .../qmake/qtquickcontrolsapplication/wizard.json | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/app.pro b/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/app.pro index 25c9afc27e7..201cfb0ee77 100644 --- a/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/app.pro +++ b/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/app.pro @@ -1,6 +1,10 @@ TEMPLATE = app +@if %{UseQApplication} QT += qml quick widgets +@else +QT += qml quick +@endif SOURCES += %{MainCppFileName} diff --git a/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/main.cpp b/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/main.cpp index 6ea3921b635..cb3ea7209aa 100644 --- a/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/main.cpp +++ b/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/main.cpp @@ -1,8 +1,12 @@ %{Cpp:LicenseTemplate}\ -%{JS: QtSupport.qtIncludes([], ["QWidgets/QApplication", "QQml/QQmlApplicationEngine"])} +%{JS: QtSupport.qtIncludes([], [%{UseQApplication} ? "QWidgets/QApplication" : "QtGui/QGuiApplication", "QQml/QQmlApplicationEngine"])} int main(int argc, char *argv[]) { +@if %{UseQApplication} QApplication app(argc, argv); +@else + QGuiApplication app(argc, argv); +@endif QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/wizard.json b/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/wizard.json index f50e5e80b93..6de9493f6ec 100644 --- a/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/wizard.json +++ b/share/qtcreator/templates/wizards/projects/qmake/qtquickcontrolsapplication/wizard.json @@ -84,6 +84,17 @@ "uncheckedValue": false, "checked": true } + }, + { + "name": "UseQApplication", + "trDisplayName": "Enable native styling. Requires dependency on the QtWidgets module.", + "type": "CheckBox", + "data": + { + "checkedValue": true, + "uncheckedValue": false, + "checked": true + } } ] },