2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2021-11-02 08:04:21 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <QCoreApplication>
|
2012-02-16 04:43:03 +00:00
|
|
|
#include <QQmlEngine>
|
|
|
|
#include <QQmlComponent>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include "birthdayparty.h"
|
|
|
|
#include "person.h"
|
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
|
|
|
{
|
|
|
|
QCoreApplication app(argc, argv);
|
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
QQmlEngine engine;
|
|
|
|
QQmlComponent component(&engine, QUrl("qrc:example.qml"));
|
2019-08-19 09:04:30 +00:00
|
|
|
auto *party = qobject_cast<BirthdayParty *>(component.create());
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if (party && party->host()) {
|
2021-11-02 08:04:21 +00:00
|
|
|
qInfo() << party->host()->name() << "is having a birthday!";
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if (qobject_cast<Boy *>(party->host()))
|
2021-11-02 08:04:21 +00:00
|
|
|
qInfo() << "He is inviting:";
|
2011-04-27 10:05:43 +00:00
|
|
|
else
|
2021-11-02 08:04:21 +00:00
|
|
|
qInfo() << "She is inviting:";
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2021-11-02 08:04:21 +00:00
|
|
|
for (qsizetype ii = 0; ii < party->guestCount(); ++ii)
|
|
|
|
qInfo() << " " << party->guest(ii)->name();
|
2019-08-19 09:07:52 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2019-08-19 09:07:52 +00:00
|
|
|
qWarning() << component.errors();
|
|
|
|
return EXIT_FAILURE;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|