当前位置: 首页>>代码示例>>C++>>正文


C++ QScriptEngine::newQMetaObject方法代码示例

本文整理汇总了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);
}
开发者ID:opentoonz,项目名称:opentoonz,代码行数:7,代码来源:scriptbinding.cpp

示例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]
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例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);
}
开发者ID:kulhanek,项目名称:cats,代码行数:6,代码来源:QTrajPool.cpp

示例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);
}
开发者ID:kulhanek,项目名称:cats,代码行数:6,代码来源:QHistogram.cpp

示例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);
}
开发者ID:kulhanek,项目名称:cats,代码行数:6,代码来源:QVolumeData.cpp


注:本文中的QScriptEngine::newQMetaObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。