Qt 5.4.1 msvc 2013 OpenGL x64
Класс:
#ifndef A_H
#define A_H
//------------------------------------------------------------------------------
#include <QtCore>
#include <QtScript>
//------------------------------------------------------------------------------
class A : public QObject
{
Q_OBJECT
Q_ENUMS(E)
public:
enum E {a,b,c};
explicit A(QObject *_parent = nullptr);
virtual ~A();
//------------------------------------------------------------------------------
static QScriptValue qscriptCtor(QScriptContext* _context, QScriptEngine *_engine)
{
return _engine->newQObject(new A,
QScriptEngine::ScriptOwnership
);
}
//------------------------------------------------------------------------------
public:
static void Init(QScriptEngine *_engine)
{
_engine->globalObject().setProperty("A", _engine->newQMetaObject(&QObject::staticMetaObject,
_engine->newFunction(qscriptCtor)
)
);
}
//------------------------------------------------------------------------------
signals:
public slots:
};
#endif // A_H
#include "a.h"
//------------------------------------------------------------------------------
A::A(QObject *_parent) : QObject(_parent)
{
}
//------------------------------------------------------------------------------
A::~A()
{
}
//------------------------------------------------------------------------------
Скрипт:
print(A.a);
var t = new A();
print(t);
print(t.a);
A() как конструктор срабатывает верно, но A.a == undefined. Что я не так делаю?