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 <Thomas.Hartmann@digia.com>
This commit is contained in:
Alessandro Portale
2015-05-19 15:54:37 +02:00
parent 1d31955abc
commit 9df3d850a1
3 changed files with 20 additions and 1 deletions

View File

@@ -1,6 +1,10 @@
TEMPLATE = app
@if %{UseQApplication}
QT += qml quick widgets
@else
QT += qml quick
@endif
SOURCES += %{MainCppFileName}

View File

@@ -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")));

View File

@@ -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
}
}
]
},