aboutsummaryrefslogtreecommitdiffstats
path: root/examples/Chronometer/QmlChronometer/main.cpp
blob: 94f8f4522814b2e2801f7bd6a6df94b096e37093 (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
27
28
29
/***************************************************************************************************
 Copyright (C) 2023 The Qt Company Ltd.
 SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/

#include "qchronometer.h"
#include "qlaprecorder.h"

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;

    QLapRecorder lapRecorder;
    engine.rootContext()->setContextProperty("laps", &lapRecorder);

    QChronometer chrono(lapRecorder);
    engine.rootContext()->setContextProperty("chrono", &chrono);

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

    return app.exec();
}