Details
-
Task
-
Resolution: Done
-
Not Evaluated
-
None
-
None
-
848a725e3b3bd51394ddbd0a10be52a8ae0bdd25
Description
Although the Qt Quick application wizard underwent a 'renovation' in 3.0 the structure & content of the generated files itself where only adapted somewhat. After some discussion the consensus seems to be that we should aim for
- Getting rid of the file by file deployment, and use qrc:// instead.
- Getting rid of the automatically generated glue code
QRC This is the most 'universal' way of deployment, and allows us to get rid of the 100 lines monster that is deployment.pri. qmlapplicationviewer.[h|cpp] and friends were hacks to allow us hiding the differences between OS versions. Using qrc:// gets rid of the problem to find the 'right' folder on the target os, while QQmlApplicationEngine (new in Qt 5.1) handles other glue code .
To get this, we should change the template for Qt Quick Controls, Qt Quick 2.0:
Qt Quick 2.1 wizard
Bump requirement to Qt 5.1.0 or newer
main.pro:
TEMPLATE = app
QT += qml quick
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
main.cpp:
#include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); return app.exec(); }
qml.qrc:
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
</qresource>
</RCC>
qml/main.qml:
import QtQuick 2.1 import QtQuick.Window 2.1 Window { visible: true width: 360 height: 360 Text { text: qsTr("Hello World") anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: { Qt.quit(); } } }
Qt Quick Controls 1.0 wizard:
main.pro:
TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
main.cpp:
#include <QtQml/QQmlApplicationEngine> #include <QtWidgets/QApplication> int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); return app.exec(); }
qml.qrc:
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
</qresource>
</RCC>
qml/main.qml:
import QtQuick 2.1 import QtQuick.Controls 1.0 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") menuBar: MenuBar { Menu { title: qsTr("File") MenuItem { text: qsTr("Exit") onTriggered: Qt.quit(); } } } Text { text: qsTr("Hello World") anchors.centerIn: parent } }
Attachments
Issue Links
- relates to
-
QTCREATORBUG-11412 Make sure deployment to device works for new QtQuick templates
-
- Closed
-
- replaces
-
QTCREATORBUG-9797 Use qrc instead of assets when making Qt Quick 2 Application on Android
-
- Closed
-
- resulted from
-
QTCREATORBUG-11277 QtQuick2ControlsApplicationViewer template generated by Qt Creator doesn't work when the QML file is a resource
-
- Closed
-
-
QTCREATORBUG-11048 Qt Quick 2 Controls Wizard has everything private so can't interface QML with C++ code
-
- Closed
-