Reader small image

You're reading from  Hands-On Embedded Programming with Qt

Product typeBook
Published inJul 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789952063
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
John Werner
John Werner
author image
John Werner

John Werner is an internationally published author, engineer, consultant, and conference speaker with more than 15 years' experience. He has earned patents for inventions ranging from Inkjet printers to automotive ignition systems. John was one of the early users of Qt on QNX and contributed to the early knowledge of how to make it work. He is a contributor to the Qt-related information on Stack Exchange. He is currently a senior software engineer, specializing in Qt development, for Caliber Imaging & Diagnostics.
Read more about John Werner

Right arrow

What if you didn't have to choose?

When we looked at the QML application, we focused purely on the QML side of things, but if you look at the HelloFromQML project and expand the sources area, you will find that there is a main.cpp file. Let's take a look at its contents:

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;

return app.exec();
}

That looks a lot like the standard main.cpp file for a Qt Widgets application, but instead of a MainWindow class being instantiated, a QQmlApplicationEngine is being created.

QML code is run in a QQmlEngine. QQmlApplicationEngine...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Embedded Programming with Qt
Published in: Jul 2019Publisher: PacktISBN-13: 9781789952063

Author (1)

author image
John Werner

John Werner is an internationally published author, engineer, consultant, and conference speaker with more than 15 years' experience. He has earned patents for inventions ranging from Inkjet printers to automotive ignition systems. John was one of the early users of Qt on QNX and contributed to the early knowledge of how to make it work. He is a contributor to the Qt-related information on Stack Exchange. He is currently a senior software engineer, specializing in Qt development, for Caliber Imaging & Diagnostics.
Read more about John Werner