本文整理汇总了C++中QScriptEngine::newQMetaObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngine::newQMetaObject方法的具体用法?C++ QScriptEngine::newQMetaObject怎么用?C++ QScriptEngine::newQMetaObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptEngine
的用法示例。
在下文中一共展示了QScriptEngine::newQMetaObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bindClass
void bindClass(QScriptEngine &engine, const QString &name) {
const QMetaObject *metaObj = &T::staticMetaObject;
QScriptValue ctor = engine.newFunction(T::ctor);
QScriptValue proto = engine.newQMetaObject(metaObj, ctor);
engine.globalObject().setProperty(name, proto);
engine.setDefaultPrototype(qMetaTypeId<T *>(), proto);
}
示例2: main
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(tetrix);
//! [1]
QApplication app(argc, argv);
QScriptEngine engine;
QScriptValue Qt = engine.newQMetaObject(QtMetaObject::get());
Qt.setProperty("App", engine.newQObject(&app));
engine.globalObject().setProperty("Qt", Qt);
//! [1]
#ifndef QT_NO_SCRIPTTOOLS
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
debugWindow->resize(1024, 640);
#endif
//! [2]
evaluateFile(engine, ":/tetrixpiece.js");
evaluateFile(engine, ":/tetrixboard.js");
evaluateFile(engine, ":/tetrixwindow.js");
//! [2]
//! [3]
TetrixUiLoader loader;
QFile uiFile(":/tetrixwindow.ui");
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
QScriptValue ctor = engine.evaluate("TetrixWindow");
QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);
QScriptValue tetrix = ctor.construct(QScriptValueList() << scriptUi);
//! [3]
QPushButton *debugButton = qFindChild<QPushButton*>(ui, "debugButton");
#ifndef QT_NO_SCRIPTTOOLS
QObject::connect(debugButton, SIGNAL(clicked()),
debugger.action(QScriptEngineDebugger::InterruptAction),
SIGNAL(triggered()));
QObject::connect(debugButton, SIGNAL(clicked()),
debugWindow, SLOT(show()));
#else
debugButton->hide();
#endif
//! [4]
ui->resize(550, 370);
ui->show();
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
return app.exec();
//! [4]
}
示例3: Register
void QTrajPool::Register(QScriptEngine& engine)
{
QScriptValue ctor = engine.newFunction(QTrajPool::New);
QScriptValue metaObject = engine.newQMetaObject(&QTrajPool::staticMetaObject, ctor);
engine.globalObject().setProperty("TrajPool", metaObject);
}
示例4: Register
void QHistogram::Register(QScriptEngine& engine)
{
QScriptValue ctor = engine.newFunction(QHistogram::New);
QScriptValue metaObject = engine.newQMetaObject(&QHistogram::staticMetaObject, ctor);
engine.globalObject().setProperty("Histogram", metaObject);
}
示例5: Register
void QVolumeData::Register(QScriptEngine& engine)
{
QScriptValue ctor = engine.newFunction(QVolumeData::New);
QScriptValue metaObject = engine.newQMetaObject(&QVolumeData::staticMetaObject, ctor);
engine.globalObject().setProperty("VolumeData", metaObject);
}