aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/referenceexamples/adding/main.cpp
blob: 319217da56713eef51f1e34d6e69addf903bbc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QCoreApplication>
#include <QQmlEngine>
#include <QQmlComponent>
#include <QDebug>
#include "person.h"

int main(int argc, char ** argv)
{
    QCoreApplication app(argc, argv);

    QQmlEngine engine;
    QQmlComponent component(&engine, QUrl("qrc:example.qml"));
    auto *person = qobject_cast<Person *>(component.create());
    if (!person) {
        qWarning() << component.errors();
        return EXIT_FAILURE;
    }

     qInfo() << "The person's name is" << person->name()
         << "\nThey wear a" << person->shoeSize() << "sized shoe";

    return EXIT_SUCCESS;
}