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


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

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


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

示例1: filesForDirectory

QScriptValue ScriptEngine::filesForDirectory (const QString &dir_)
{
    QString dir = dir_;

    QDir directory(dir);

    if(!directory.exists()) {
        return myengine.undefinedValue();
    }

    QStringList files = directory.entryList(QDir::Files);
    QScriptValue ret = myengine.newArray(files.count());

    for (int i = 0; i < files.size(); i++) {
        ret.setProperty(i, files[i]);
    }

    return ret;
}
开发者ID:ElementsPO,项目名称:pokemon-online,代码行数:19,代码来源:scriptengine.cpp

示例2: qtscript_create_QStateMachine_SignalEvent_class

QScriptValue qtscript_create_QStateMachine_SignalEvent_class(QScriptEngine *engine)
{
    engine->setDefaultPrototype(qMetaTypeId<QStateMachine::SignalEvent*>(), QScriptValue());
    QScriptValue proto = engine->newVariant(qVariantFromValue((QStateMachine::SignalEvent*)0));
    proto.setPrototype(engine->defaultPrototype(qMetaTypeId<QEvent*>()));
    for (int i = 0; i < 4; ++i) {
        QScriptValue fun = engine->newFunction(qtscript_QStateMachine_SignalEvent_prototype_call, qtscript_QStateMachine_SignalEvent_function_lengths[i+1]);
        fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));
        proto.setProperty(QString::fromLatin1(qtscript_QStateMachine_SignalEvent_function_names[i+1]),
                          fun, QScriptValue::SkipInEnumeration);
    }

    engine->setDefaultPrototype(qMetaTypeId<QStateMachine::SignalEvent*>(), proto);

    QScriptValue ctor = engine->newFunction(qtscript_QStateMachine_SignalEvent_static_call, proto, qtscript_QStateMachine_SignalEvent_function_lengths[0]);
    ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));

    return ctor;
}
开发者ID:ppiecuch,项目名称:qcad,代码行数:19,代码来源:qtscript_QStateMachine_SignalEvent.cpp

示例3: additionalProperty

QScriptValue EnumScriptClass::additionalProperty(const DataInformation* data, const QScriptString& name, uint id)
{
    if (name == s_values)
    {
        const EnumDataInformation* pData = data->asEnum();
        QScriptValue ret = engine()->newObject();
        QMapIterator<AllPrimitiveTypes, QString> it(pData-> enumValues()->values());
        while(it.hasNext()) {
            it.next();
            ret.setProperty(it.value(), QString::number(it.key().value<quint64>())); //should always work
        }
        return ret;
    }
    else if (name == s_type)
    {
        return data->typeName();
    }
    return PrimitiveScriptClass::additionalProperty(data, name, id);
}
开发者ID:KDE,项目名称:okteta,代码行数:19,代码来源:enumscriptclass.cpp

示例4: qtscript_create_QWhatsThis_class

QScriptValue qtscript_create_QWhatsThis_class(QScriptEngine *engine)
{
    engine->setDefaultPrototype(qMetaTypeId<QWhatsThis*>(), QScriptValue());
    QScriptValue proto = engine->newVariant(qVariantFromValue((QWhatsThis*)0));

    engine->setDefaultPrototype(qMetaTypeId<QWhatsThis*>(), proto);

    QScriptValue ctor = engine->newFunction(qtscript_QWhatsThis_static_call, proto, qtscript_QWhatsThis_function_lengths[0]);
    ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));
    for (int i = 0; i < 6; ++i) {
        QScriptValue fun = engine->newFunction(qtscript_QWhatsThis_static_call,
            qtscript_QWhatsThis_function_lengths[i+1]);
        fun.setData(QScriptValue(engine, uint(0xBABE0000 + i+1)));
        ctor.setProperty(QString::fromLatin1(qtscript_QWhatsThis_function_names[i+1]),
            fun, QScriptValue::SkipInEnumeration);
    }

    return ctor;
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:19,代码来源:qtscript_QWhatsThis.cpp

示例5: getSet

//! [78]
QScriptValue getSet(QScriptContext *ctx, QScriptEngine *eng)
{
    QScriptValue obj = ctx->thisObject();
    QScriptValue data = obj.data();
    if (!data.isValid()) {
        data = eng->newObject();
        obj.setData(data);
    }
    QScriptValue result;
    if (ctx->argumentCount() == 1) {
        QString str = ctx->argument(0).toString();
        str.replace("Roberta", "Ken");
        result = str;
        data.setProperty("x", result);
    } else {
        result = data.property("x");
    }
    return result;
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:20,代码来源:doc_src_qtscript.cpp

示例6: qtscript_create_QGraphicsRectItem_class

QScriptValue qtscript_create_QGraphicsRectItem_class(QScriptEngine *engine)
{
    engine->setDefaultPrototype(qMetaTypeId<QGraphicsRectItem*>(), QScriptValue());
    QScriptValue proto = engine->newVariant(qVariantFromValue((QGraphicsRectItem*)0));
    proto.setPrototype(engine->defaultPrototype(qMetaTypeId<QAbstractGraphicsShapeItem*>()));
    for (int i = 0; i < 3; ++i) {
        QScriptValue fun = engine->newFunction(qtscript_QGraphicsRectItem_prototype_call, qtscript_QGraphicsRectItem_function_lengths[i+1]);
        fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));
        proto.setProperty(QString::fromLatin1(qtscript_QGraphicsRectItem_function_names[i+1]),
            fun, QScriptValue::SkipInEnumeration);
    }

    engine->setDefaultPrototype(qMetaTypeId<QGraphicsRectItem*>(), proto);

    QScriptValue ctor = engine->newFunction(qtscript_QGraphicsRectItem_static_call, proto, qtscript_QGraphicsRectItem_function_lengths[0]);
    ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));

    return ctor;
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:19,代码来源:qtscript_QGraphicsRectItem.cpp

示例7: qtscript_create_QXmlReader_class

QScriptValue qtscript_create_QXmlReader_class(QScriptEngine *engine)
{
    static const int function_lengths[] = {
        0
        // static
        // prototype
        , 0
        , 0
        , 0
        , 0
        , 0
        , 2
        , 1
        , 1
        , 0
        , 1
        , 2
        , 1
        , 1
        , 1
        , 1
        , 1
        , 2
        , 1
        , 2
        , 0
    };
    engine->setDefaultPrototype(qMetaTypeId<QXmlReader*>(), QScriptValue());
    QScriptValue proto = engine->newVariant(qVariantFromValue((QXmlReader*)0));
    for (int i = 0; i < 20; ++i) {
        QScriptValue fun = engine->newFunction(qtscript_QXmlReader_prototype_call, function_lengths[i+1]);
        fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));
        proto.setProperty(QString::fromLatin1(qtscript_QXmlReader_function_names[i+1]),
            fun, QScriptValue::SkipInEnumeration);
    }

    engine->setDefaultPrototype(qMetaTypeId<QXmlReader*>(), proto);

    QScriptValue ctor = engine->newFunction(qtscript_QXmlReader_static_call, proto, function_lengths[0]);
    ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));

    return ctor;
}
开发者ID:SSMN,项目名称:MuseScore,代码行数:43,代码来源:qtscript_QXmlReader.cpp

示例8: VERIFY

static QScriptValue argumentsObjectInNative_test1(QScriptContext *ctx, QScriptEngine *eng)
{
#define VERIFY(statement) \
    do {\
        if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
            return QString::fromLatin1("Failed "  #statement);\
    } while (0)

    QScriptValue obj = ctx->argumentsObject();
    VERIFY(obj.isObject());
    VERIFY(obj.property(0).toUInt32() == 123);
    VERIFY(obj.property(1).toString() == QString::fromLatin1("456"));

    obj.setProperty(0, "abc");
    VERIFY(eng->evaluate("arguments[0]").toString() == QString::fromLatin1("abc") );

    return QString::fromLatin1("success");
#undef VERIFY
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:19,代码来源:tst_qscriptcontext.cpp

示例9: toScriptValue

QScriptValue AdditionalDataRequest::toScriptValue( QScriptEngine *engine ) const
{
    QScriptValue value = engine->newObject();
    value.setProperty( QLatin1String("stop"), m_stop );
    value.setProperty( QLatin1String("city"), m_city );
    value.setProperty( QLatin1String("dataType"),
            m_sourceName.startsWith(QLatin1String("Arrivals"), Qt::CaseInsensitive)
            ? parseModeName(ParseForArrivals) : parseModeName(ParseForDepartures));
    value.setProperty( QLatin1String("transportLine"), m_transportLine );
    value.setProperty( QLatin1String("target"), m_target );
    value.setProperty( QLatin1String("dateTime"), engine->newDate(m_dateTime) );
    value.setProperty( QLatin1String("routeDataUrl"), m_routeDataUrl );
    return value;
}
开发者ID:janLo,项目名称:PlansmaPublicTransport,代码行数:14,代码来源:request.cpp

示例10: toBattleChoice

static QScriptValue toBattleChoice(QScriptEngine *e, const BattleChoice& info) {
    QScriptValue v = e->newObject();
    v.setProperty("type", bchoices.count() > info.type ? bchoices[info.type] : "unknown");
    v.setProperty("slot", int(info.slot()));
    if (info.attackingChoice()) {
        v.setProperty("attackSlot", int(info.attackSlot()));
        v.setProperty("target", int(info.target()));
    } else if (info.switchChoice()) {
        v.setProperty("pokeSlot", int(info.pokeSlot()));
    } else if (info.rearrangeChoice()) {
        QScriptValue v2 = e->newArray();
        for (int i = 0; i < 6; i++) {
            v2.setProperty(i, int(info.choice.rearrange.pokeIndexes[i]));
        }
        v.setProperty("neworder", v2);
    } else if (info.itemChoice()) {
        v.setProperty("item", info.item());
        v.setProperty("target", info.itemTarget());
        v.setProperty("attack", info.itemAttack());
    }
    return v;
}
开发者ID:Angryn00b,项目名称:pokemon-online,代码行数:22,代码来源:battlescripting.cpp

示例11: initObject

QScriptValue PHISRequestObj::initObject( QScriptEngine *engine, const QString &mod )
{
    QScriptValue request=PHISScriptObj::initObject( engine, mod );
    QScriptValue arr=engine->newArray();
    QStringList values, keys;
    QString value, key, props=QStringLiteral( "properties" );
    int i=0, l;

    QScriptValue sv=engine->newObject();
    QScriptValue subarr;
    request.setProperty( QStringLiteral( "post" ), sv );
    keys=PHIS_IF()->postKeys();
    foreach( key, keys ) {
        values=PHIS_IF()->postValues( key );
        subarr=engine->newArray();
        l=0;
        foreach ( value, values ) subarr.setProperty( l++, value );
        sv.setProperty( key, subarr );
        arr.setProperty( i++, key );
    }
开发者ID:TheAppsDude,项目名称:phisketeer,代码行数:20,代码来源:phisreqrep.cpp

示例12: js_enumGroup

static QScriptValue js_enumGroup(QScriptContext *context, QScriptEngine *engine)
{
	int groupId = context->argument(0).toInt32();
	QList<DROID *> matches;
	DROID_GROUP *psGroup = grpFind(groupId);
	DROID *psCurr;

	SCRIPT_ASSERT(context, psGroup, "Invalid group index %d", groupId);
	for (psCurr = psGroup->psList; psCurr != NULL; psCurr = psCurr->psGrpNext)
	{
		matches.push_back(psCurr);
	}
	QScriptValue result = engine->newArray(matches.size());
	for (int i = 0; i < matches.size(); i++)
	{
		DROID *psDroid = matches.at(i);
		result.setProperty(i, convDroid(psDroid, engine));
	}
	return result;
}
开发者ID:RomanoFC,项目名称:warzone2100,代码行数:20,代码来源:qtscriptfuncs.cpp

示例13: qtscript_create_QProgressDialog_class

QScriptValue qtscript_create_QProgressDialog_class(QScriptEngine *engine)
{
    engine->setDefaultPrototype(qMetaTypeId<QProgressDialog*>(), QScriptValue());
    QScriptValue proto = engine->newVariant(qVariantFromValue((QProgressDialog*)0));
    proto.setPrototype(engine->defaultPrototype(qMetaTypeId<QDialog*>()));
    for (int i = 0; i < 5; ++i) {
        QScriptValue fun = engine->newFunction(qtscript_QProgressDialog_prototype_call, qtscript_QProgressDialog_function_lengths[i+1]);
        fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));
        proto.setProperty(QString::fromLatin1(qtscript_QProgressDialog_function_names[i+1]),
            fun, QScriptValue::SkipInEnumeration);
    }

    qScriptRegisterMetaType<QProgressDialog*>(engine, qtscript_QProgressDialog_toScriptValue, 
        qtscript_QProgressDialog_fromScriptValue, proto);

    QScriptValue ctor = engine->newFunction(qtscript_QProgressDialog_static_call, proto, qtscript_QProgressDialog_function_lengths[0]);
    ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));

    return ctor;
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:20,代码来源:qtscript_QProgressDialog.cpp

示例14: setupCLineEdit

void setupCLineEdit(QScriptEngine *engine)
{
  QScriptValue widget = engine->newObject();

  widget.setProperty("AllCustomers",	           QScriptValue(engine, CLineEdit::AllCustomers),	        QScriptValue::ReadOnly | QScriptValue::Undeletable);
  widget.setProperty("ActiveCustomers",	           QScriptValue(engine, CLineEdit::ActiveCustomers), 	        QScriptValue::ReadOnly | QScriptValue::Undeletable);
  widget.setProperty("AllProspects",	           QScriptValue(engine, CLineEdit::AllProspects),	        QScriptValue::ReadOnly | QScriptValue::Undeletable);
  widget.setProperty("ActiveProspects",	           QScriptValue(engine, CLineEdit::ActiveProspects),	        QScriptValue::ReadOnly | QScriptValue::Undeletable);
  widget.setProperty("AllCustomersAndProspects",   QScriptValue(engine, CLineEdit::AllCustomersAndProspects),	QScriptValue::ReadOnly | QScriptValue::Undeletable);
  widget.setProperty("ActiveCustomersAndProspects",QScriptValue(engine, CLineEdit::ActiveCustomersAndProspects),QScriptValue::ReadOnly | QScriptValue::Undeletable);

  engine->globalObject().setProperty("CLineEdit", widget, QScriptValue::ReadOnly | QScriptValue::Undeletable);

  qScriptRegisterMetaType(engine, CLineEditTypesToScriptValue, CLineEditTypesFromScriptValue);
}
开发者ID:ChristopherCotnoir,项目名称:qt-client,代码行数:15,代码来源:clineeditsetup.cpp

示例15: dirsForDirectory

QScriptValue ScriptEngine::dirsForDirectory (const QString &dir_)
{
    QString dir = dir_;

    QDir directory(dir);

    if(!directory.exists()) {
        return myengine.undefinedValue();
    }

    QStringList dirs = directory.entryList(QDir::Dirs);
    QScriptValue ret = myengine.newArray(dirs.size());

    for (int i = 0; i < dirs.size(); i++) {
        if (dirs[i] != "." && dirs[i] != "..") {
            ret.setProperty(i, dirs[i]);
        }
    }

    return ret;
}
开发者ID:ElementsPO,项目名称:pokemon-online,代码行数:21,代码来源:scriptengine.cpp


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