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


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

本文整理汇总了C++中QScriptEngine::installTranslatorFunctions方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngine::installTranslatorFunctions方法的具体用法?C++ QScriptEngine::installTranslatorFunctions怎么用?C++ QScriptEngine::installTranslatorFunctions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QScriptEngine的用法示例。


在下文中一共展示了QScriptEngine::installTranslatorFunctions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QScriptEngine

QScriptEngine * PERPScriptEngine::newEngine(QObject *parent, QScriptEngineDebugger *debugger)
{
	QScriptEngine *engine = new QScriptEngine(parent);
	if ( debugger != NULL ) {
		debugger->attachTo(engine);
	}
	PERPScriptEngine::registerScriptsTypes(engine);
	engine->installTranslatorFunctions();
	PERPScriptEngine::importExtensions(engine);
	return engine;
}
开发者ID:BaconGo,项目名称:alepherp,代码行数:11,代码来源:perpscriptengine.cpp

示例2: main

//! [0]
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(helloscript);
//! [0]

//! [1]
    QApplication app(argc, argv);

    QScriptEngine engine;

    QTranslator translator;
    translator.load("helloscript_la");
    app.installTranslator(&translator);
    engine.installTranslatorFunctions();
//! [1]

//! [2]
    QPushButton button;
    QScriptValue scriptButton = engine.newQObject(&button);
    engine.globalObject().setProperty("button", scriptButton);
//! [2]

//! [3]
    QString fileName(":/helloscript.js");
    QFile scriptFile(fileName);
    scriptFile.open(QIODevice::ReadOnly);
    QTextStream stream(&scriptFile);
    QString contents = stream.readAll();
    scriptFile.close();
//! [3]

#ifdef Q_OS_SYMBIAN
    contents.replace("button.show()", "button.showMaximized()");
#endif

//! [4]
    QScriptValue result = engine.evaluate(contents, fileName);
//! [4]

//! [5]
    if (result.isError()) {
        QMessageBox::critical(0, "Hello Script",
                              QString::fromLatin1("%0:%1: %2")
                              .arg(fileName)
                              .arg(result.property("lineNumber").toInt32())
                              .arg(result.toString()));
        return -1;
    }
//! [5]

//! [6]
    return app.exec();
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:54,代码来源:main.cpp

示例3: main

int main(int argc, char **argv)
{
    QApplication *app = new QApplication(argc, argv);
    app->setApplicationName("kross");
    app->setApplicationVersion("0.1");
    app->setOrganizationDomain("dipe.org");

    QScriptEngine *engine = new QScriptEngine();
    engine->installTranslatorFunctions();

    /*K4AboutData about("kross",0,ki18n("Kross"),"0.1",
                     ki18n("KDE application to run Kross scripts."),
                     K4AboutData::License_LGPL,
                     ki18n("(C) 2006 Sebastian Sauer"),
                     ki18n("Run Kross scripts."),
                     "http://kross.dipe.org","[email protected]");*/
    //about.addAuthor(ki18n("Sebastian Sauer"), ki18n("Author"), "[email protected]");

    // Initialize command line args
    // Tell which options are supported and parse them.
    QCommandLineParser parser;
    parser.setApplicationDescription(QCoreApplication::translate("main", "KDE application to run Kross scripts."));
    parser.addHelpOption();
    parser.addOption(QCommandLineOption(QStringList() << "+file", QCoreApplication::translate("main", "Scriptfile")));
    parser.process(*app);

    const QStringList args = parser.positionalArguments();
    // If no options are defined.
    if (args.count() < 1) {
        parser.showHelp();
        //std::cout << "Syntax: " << "kross" << " scriptfile1 [scriptfile2] [scriptfile3] ..." << std::endl;
        return -1;
    }

    QScriptValue global = engine->globalObject();

    //qDebug()<<"QLibraryInfo::PluginsPath="<<QLibraryInfo::location(QLibraryInfo::PluginsPath);

    engine->importExtension("kross").toString();

    foreach (const QString &file, args) {
        runScriptFile(engine, file);
    }
开发者ID:KDE,项目名称:kross,代码行数:43,代码来源:qts.cpp


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