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


C++ QScriptValue::isError方法代码示例

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


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

示例1: read

QScriptValue QTrajectory::read(void)
{
    QScriptValue value;

// help ------------------------------------------
    if( IsHelpRequested() ){
        CTerminalStr sout;
        sout << "usage: snapshot Trajectory::read(snapshot)" << endl;
        sout << "       snapshot Trajectory::read()" << endl;
        return(false);
    }

// check arguments -------------------------------
    value = CheckNumberOfArguments("[snapshot]",0,1);
    if( value.isError() ) return(value);

    QSnapshot* p_qsnap = NULL;
    if( GetArgumentCount() == 1 ){
        value = GetArgAsObject<QSnapshot*>("snapshot","snapshot","Snapshot",1,p_qsnap);
        if( value.isError() ) return(value);
    } else {
        p_qsnap = new QSnapshot(Topology);
    }

// execute ---------------------------------------
    if( Trajectory.GetOpenMode() != AMBER_TRAJ_READ ){
        return( ThrowError("snapshot","trajectory is not opened for reading") );
    }
    bool result = Trajectory.ReadSnapshot(&p_qsnap->Restart);
    if( result ){
        CurrentSnapshot++;
    } else {
        if( GetArgumentCount() == 0 ){
            delete p_qsnap;
        }
        return( GetUndefinedValue() );
    }
    if( GetArgumentCount() == 1 ){
        return(GetArgument(1));
    } else {
        return(engine()->newQObject(p_qsnap, QScriptEngine::ScriptOwnership));
    }
}
开发者ID:kulhanek,项目名称:cats,代码行数:43,代码来源:QTrajectory.cpp

示例2: addTrajectory

QScriptValue QTrajPool::addTrajectory(void)
{
    QScriptValue value;

// help ------------------------------------------
    if( IsHelpRequested() ){
        CTerminalStr sout;
        sout << "usage: bool TrajPool::addTrajectory(name[,format])" << endl;
        sout << "       format: ascii      - ASCII format" << endl;
        sout << "               ascii.gzip - compressed ASCII format" << endl;
        sout << "               ascii.bzip - compressed ASCII format" << endl;
        sout << "               netcdf     - NETCDF format" << endl;
        return(false);
    }

// check arguments -------------------------------
    value = CheckNumberOfArguments("name",1,2);
    if( value.isError() ) return(value);

    QString name;
    value = GetArgAsString("name[,format]","name",1,name);
    if( value.isError() ) return(value);

    QString format = "unknown";
    if( GetArgumentCount() == 2 ){
        value = GetArgAsString("name,format","format",2,format);
        if( value.isError() ) return(value);
    }

// execute ---------------------------------------
    if( addTrajFile(name,format) == false ){
        if( IgnoreMissingFiles == true ) return(true);
        CSmallString error;
        if( format == "unknown" ){
            error << "unable to add file '" << CSmallString(name) << "'";
        } else {
            error << "unable to add file '" << CSmallString(name) << "' with format '" << CSmallString(format) << "'";
        }
        return( ThrowError("name[,format]",error));
    }
    return(true);
}
开发者ID:kulhanek,项目名称:cats,代码行数:42,代码来源:QTrajPool.cpp

示例3: add

QScriptValue ImageBuilder::add(QScriptValue imgArg) {
  Image *simg      = 0;
  QScriptValue err = checkImage(context(), imgArg, simg);
  if (err.isError()) return err;
  QString errStr = add(simg->getImg(), TAffine());
  if (errStr != "")
    return context()->throwError(
        tr("%1 : %2").arg(errStr).arg(imgArg.toString()));
  else
    return context()->thisObject();
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:11,代码来源:scriptbinding_image_builder.cpp

示例4: emscriptenQtSDLMain

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

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

    engine = new QScriptEngine;

    QTranslator *translator = new QTranslator;
    translator->load("helloscript_la");
    app->installTranslator(translator);
    engine->installTranslatorFunctions();
//! [1]

//! [2]
    QPushButton *button = new QPushButton;
    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:RobertoMalatesta,项目名称:emscripten-qt,代码行数:54,代码来源:main.cpp

示例5: on_console_execute

void shell::on_console_execute(const QString& Command)
{
	QScriptValue result = script_engine->evaluate(Command);

	if(result.isError())
		ui.console->print_html("<span style='color: #f00'>" + result.toString() + "</span>");
	else if(!result.isUndefined())
		ui.console->print_html("<span style='color: #00f'>" + result.toString() + "</span>");
	
	prompt();
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:11,代码来源:shell.cpp

示例6: printProgress

QScriptValue  QTrajectory::printProgress(void)
{
    QScriptValue value;

// help ------------------------------------------
    if( IsHelpRequested() ){
        CTerminalStr sout;
        sout << "usage: Trajectory::printProgress()" << endl;
        return(false);
    }

// check arguments -------------------------------
    value = CheckNumberOfArguments("",0);
    if( value.isError() ) return(value);

// execute ---------------------------------------
    if( Trajectory.IsItOpened() == false ){
        return(ThrowError("","trajectory is not opened"));
    }

    if( ProgressStarted == false ){
        cout << setw(15) << left << Name.toStdString() << " |";
        ProgressStarted = true;
        ProgressSnapshot = 0;
    }
    if( ProgressStarted ){
        if( ProgressSnapshot > Trajectory.GetNumberOfSnapshots() ) return(value);

        for(int i=ProgressSnapshot;i < CurrentSnapshot; i++){
            if( Trajectory.GetNumberOfSnapshots() > 80 ){
                if( i % (Trajectory.GetNumberOfSnapshots()/80) == 0 ){
                    cout << "=";
                }
            }
            if( i == Trajectory.GetNumberOfSnapshots()/4 ){
                cout << " 25% ";
            }
            if( i == Trajectory.GetNumberOfSnapshots()/2 ){
                cout << " 50% ";
            }
            if( i == 3*Trajectory.GetNumberOfSnapshots()/4 ){
                cout << " 75% ";
            }
        }
        ProgressSnapshot = CurrentSnapshot;
        if( CurrentSnapshot == Trajectory.GetNumberOfSnapshots() ){
                cout << "|" << endl;
        }
        cout.flush();
    }

    return(value);
}
开发者ID:kulhanek,项目名称:cats,代码行数:53,代码来源:QTrajectory.cpp

示例7: start

bool CodeExecuter::start(QIODevice *device, const QString &filename)
{
	if(!Executer::start(device, filename))
		return false;
	
	QString code = QString::fromUtf8(device->readAll());
	device->close();
	
	mScriptAgent->setContext(LibExecuter::ScriptAgent::ActionInit);
    LibExecuter::CodeInitializer::initialize(mScriptEngine, mScriptAgent, actionFactory(), filename);

	Code::CodeTools::addClassToScriptEngine<LibExecuter::CodeStdio>(QStringLiteral("Console"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::print, QStringLiteral("print"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::println, QStringLiteral("println"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printWarning, QStringLiteral("printWarning"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printlnWarning, QStringLiteral("printlnWarning"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printError, QStringLiteral("printError"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printlnError, QStringLiteral("printlnError"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::clear, QStringLiteral("clear"), mScriptEngine);

	Code::CodeTools::addClassToScriptEngine<LibExecuter::CodeActiona>(QStringLiteral("Actiona"), mScriptEngine);
    LibExecuter::CodeActiona::setActExec(true);
    LibExecuter::CodeActiona::setActionaVersion(Global::ACTIONA_VERSION);
    LibExecuter::CodeActiona::setScriptVersion(Global::SCRIPT_VERSION);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::version, QStringLiteral("version"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::scriptVersion, QStringLiteral("scriptVersion"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::isActExec, QStringLiteral("isActExec"), mScriptEngine);
	Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::isActiona, QStringLiteral("isActiona"), mScriptEngine);

    QString locale = Tools::Languages::locale();

	for(int actionPackIndex = 0; actionPackIndex < actionFactory()->actionPackCount(); ++actionPackIndex)
	{
		ActionTools::ActionPack *actionPack = actionFactory()->actionPack(actionPackIndex);

        Tools::Languages::installTranslator(QStringLiteral("actionpack%1").arg(actionPack->id()), locale);
	}

	mScriptAgent->setContext(LibExecuter::ScriptAgent::Parameters);
	
	QScriptValue result = mScriptEngine->evaluate(code, filename);
	if(result.isError())
	{
		QTextStream stream(stdout);
		stream << QObject::tr("Uncaught exception: ") << result.toString() << "\n";
		stream << tr("Backtrace: ") << mScriptEngine->uncaughtExceptionBacktrace().join(QStringLiteral("\n")) << "\n";
		stream.flush();
	}
	
	QTimer::singleShot(0, qApp, SLOT(quit()));
	
	return true;
}
开发者ID:Jmgr,项目名称:actiona,代码行数:53,代码来源:codeexecuter.cpp

示例8: customToString

QString ScriptHandler::customToString(const DataInformation* data, const QScriptValue& func)
{
    Q_ASSERT(func.isValid());
    Q_ASSERT(func.isFunction());
    Q_ASSERT(data->wasAbleToRead()); //this should never be called if EOF was reached
    //it is effectively const, since nothing may be modified while mode is CustomToString
    //const_cast is okay in this case
    QScriptValue result = callFunction(func, const_cast<DataInformation*>(data), ScriptHandlerInfo::CustomToString);
    if (result.isError())
        data->logError() << "toStringFunc caused an error:" << result.toString();
    return result.toString();
}
开发者ID:KDE,项目名称:okteta,代码行数:12,代码来源:scripthandler.cpp

示例9: backtrace

QString KateScript::backtrace( const QScriptValue& error, const QString& header )
{
  QString bt;
  if(!header.isNull())
    bt += header + ":\n";
  if(error.isError())
    bt += error.toString() + '\n';

  bt += m_engine->uncaughtExceptionBacktrace().join("\n") + '\n';

  return bt;
}
开发者ID:azat-archive,项目名称:kate,代码行数:12,代码来源:katescript.cpp

示例10: call

QScriptValue PluginsScript::call(QString sScript, QString sFunctionName, QScriptValueList valuelist,QString sExtra)
{
    // TODO check if function
    QScriptValue script = evaluate(sScript);
    if(!script.isError())
    {
        QScriptValue detect=globalObject().property(sFunctionName);
        if(!detect.isError())
        {

            QScriptValue result=detect.call(script,valuelist);
            if(!result.isError())
            {
                return result;
            }
            else
            {
                if(sExtra!="")
                {
                    emit appendError(QString("%1: %2").arg(sExtra).arg(result.toString()));
                }
                else
                {
                    emit appendError(QString("%1").arg(result.toString()));
                }
            }
        }
        else
        {
            if(sExtra!="")
            {
                emit appendError(QString("%1: %2").arg(sExtra).arg(detect.toString()));
            }
            else
            {
                emit appendError(QString("%1").arg(detect.toString()));
            }
        }
    }
    else
    {
        if(sExtra!="")
        {
            emit appendError(QString("%1: %2").arg(sExtra).arg(script.toString()));
        }
        else
        {
            emit appendError(QString("%1").arg(script.toString()));
        }
    }

    return 0;
}
开发者ID:hypn0chka,项目名称:DIE-engine,代码行数:53,代码来源:pluginsscript.cpp

示例11: submitSettingsResponse

void JavaScriptDecaptchaPlugin::submitSettingsResponse(const QVariantMap &settings) {
    if (!init()) {
        error(tr("Plugin not initialized"));
        return;
    }

    if (m_callback.isFunction()) {
        const QScriptValue result = m_callback.call(m_plugin, QScriptValueList()
                << m_plugin.engine()->toScriptValue(settings));

        if (result.isError()) {
            const QString errorString = result.toString();
            Logger::log("JavaScriptDecaptchaPlugin::submitSettingsResponse(): Error calling settings callback: "
                    + errorString);
            emit error(tr("Settings callback error: %1").arg(errorString));
        }
    }
    else {
        const QString funcName = m_callback.toString();
        QScriptValue func = m_plugin.property(funcName);

        if (func.isFunction()) {
            const QScriptValue result = func.call(m_plugin, QScriptValueList()
                    << m_plugin.engine()->toScriptValue(settings));

            if (result.isError()) {
                const QString errorString = result.toString();
                Logger::log("JavaScriptDecaptchaPlugin::submitSettingsResponse(): Error calling settings callback: "
                        + errorString);
                emit error(tr("Settings callback error: %1").arg(errorString));
            }
        }
        else {
            Logger::log(QString("JavaScriptDecaptchaPlugin::submitSettingsResponse(): %1 function not defined")
                    .arg(funcName));
            emit error(tr("%1 function not defined in the plugin").arg(funcName));
        }
    }
}
开发者ID:marxoft,项目名称:qdl2,代码行数:39,代码来源:javascriptdecaptchaplugin.cpp

示例12: slNewPiece

void PlugScript::slNewPiece(InterfaceTetris tpD)
{


    ifTetris=&tpD;
//    QByteArray     tpCur( tpD.aBoard);
    iWaiting=0;

    QScriptEngine scrptEngine;
    QFile         file("d:\\ETK\\Projects\\qt\\tetrisqt\\tetris.js");
    if (!file.open(QFile::ReadOnly)) {
        QMessageBox::critical(0,
                              QString("File open error"),
                               "Can not open the script file:"+file.fileName() ,
                              QMessageBox::Yes
                             );

    }
    QLabel  lb;
    QScriptValue objTetris=scrptEngine.newQObject(&lb);
    scrptEngine.globalObject().setProperty("objTetris", objTetris);

    //objTetris.setProperty("mBoard",tpCur);
    //scrptEngine.globalObject().setProperty("iTetris",interfaceTetris);
    //QScriptValue val=scrptEngine.evaluate("");
    QString str=QLatin1String(file.readAll());



    scrptEngine.globalObject().setProperty("foo", 123);

    QScriptValue result =
        scrptEngine.evaluate(str);


//    Q_ASSERT(result);

    if (result.isError()) {
        QMessageBox::critical(0,
                              "Evaluating error",
                              result.toString(),
                              QMessageBox::Yes
                             );
    }



    iLines++;
    emit sgDbg(result.toInteger());

}
开发者ID:patratskiy,项目名称:Test,代码行数:51,代码来源:plugscript.cpp

示例13: throwValue

void tst_QScriptContext::throwValue()
{
    QScriptEngine eng;

    QScriptValue fun = eng.newFunction(throw_value);
    eng.globalObject().setProperty("throw_value", fun);

    {
        QScriptValue result = eng.evaluate("throw_value(123)");
        QCOMPARE(result.isError(), false);
        QCOMPARE(result.toNumber(), 123.0);
        QCOMPARE(eng.hasUncaughtException(), true);
    }
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:14,代码来源:tst_qscriptcontext.cpp

示例14: setName

QScriptValue QHistogram::setName(const QScriptValue& dummy)
{
    QScriptValue value;

// help ------------------------------------------
    if( IsHelpRequested() ){
        CTerminalStr sout;
        sout << "usage: LinStat::setName(name)" << endl;
        return(false);
    }

// check arguments -------------------------------
    value = CheckNumberOfArguments("name",1);
    if( value.isError() ) return(value);

    QString name;
    value = GetArgAsString("name","name",1,name);
    if( value.isError() ) return(value);

// execute ---------------------------------------
    Name = name;
    return(true);
}
开发者ID:kulhanek,项目名称:cats,代码行数:23,代码来源:QHistogram.cpp

示例15: setOutlierValue

QScriptValue QVolumeData::setOutlierValue(void)
{
    QScriptValue value;

// help ------------------------------------------
    if( IsHelpRequested() ){
        CTerminalStr sout;
        sout << "usage: VolumeData::setOutlierValue(value)" << endl;
        return(false);
    }

// check arguments -------------------------------
    value = CheckNumberOfArguments("value",1);
    if( value.isError() ) return(value);

    double outval;
    value = GetArgAsRNumber("value","value",1,outval);
    if( value.isError() ) return(value);

// execute ---------------------------------------
    OutlierValue = outval;
    return(value);
}
开发者ID:kulhanek,项目名称:cats,代码行数:23,代码来源:QVolumeData.cpp


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