blob: 93d0ccfa881bf47853563d14da2ebe3a57b1c8c9 (
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
30
31
32
33
34
35
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QTextEdit>
#include <QTimer>
#include <QtScript>
#include "myobject.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QScriptEngine engine;
QFile scriptFile(":/object.js");
scriptFile.open(QFile::ReadOnly);
engine.evaluate(scriptFile.readAll());
scriptFile.close();
QTextEdit editor;
QTimer timer;
QScriptValue constructor = engine.evaluate("Object");
QScriptValueList arguments;
arguments << engine.newQObject(&timer);
arguments << engine.newQObject(&editor);
QScriptValue object = constructor.construct(arguments);
if (engine.hasUncaughtException()) {
qDebug() << engine.uncaughtException().toString();
}
editor.show();
timer.start(1000);
return app.exec();
}
|