Integrating Qt Quick and C++

You can run a simple Qt Quick application using the qmlviewer application, an application provided as part of the Qt SDK. However, most of the time, you'll create a Qt Quick application using the Qt Quick application wizard in Qt Creator, which results in a hybrid application consisting of a Qt C++ application container and QML files as resources that the application loads and plays at runtime.

If we take a look at main.cpp in a project that we create with this wizard, we will see the following code:

#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); return app.exec(); ...

Get Application Development with Qt Creator - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.