Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QtCore>
4#include <QtQuick>
5
6int main(int argc, char *argv[])
7{
8 QCoreApplication app(argc, argv);
9
10//![0]
11// main.cpp
12QQmlEngine engine;
13QQmlComponent component(&engine, "MyItem.qml");
14QObject *object = component.create();
15
16QString returnedValue;
17QString msg = "Hello from C++";
18QMetaObject::invokeMethod(object, "myQmlFunction",
19 Q_RETURN_ARG(QString, returnedValue),
20 Q_ARG(QString, msg));
21
22qDebug() << "QML function returned:" << returnedValue;
23delete object;
24//![0]
25}
int main(int argc, char *argv[])
[ctor_close]