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
4#include <QObject>
5#include <QtQml>
6#include "myobject.h"
7
8int main(int argc, char *argv[])
9{
10 QCoreApplication app(argc, argv);
11 //! [0]
12 QJSEngine engine;
13 QObject *someObject = new MyObject;
14 QJSValue objectValue = engine.newQObject(someObject);
15 engine.globalObject().setProperty("myObject", objectValue);
16 //! [0]
17 qDebug() << "myObject's calculate() function returns"
18 << engine.evaluate("myObject.calculate(10)").toNumber();
19 return 0;
20}
int main(int argc, char *argv[])
[ctor_close]