Time for action – Creating the first project

Let's create a project to better understand what QML is. In Qt Creator, select File and then New File or Project in the main menu. Choose Application in the left column and select the Qt Quick Application - Empty template. Name the project as calculator and go through the rest of the wizard.

Qt Creator created a sample application that displays an empty window. Let's examine the project files. The first file is the usual main.cpp:

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

Get Game Programming using Qt 5 Beginner's Guide - 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.