本文整理汇总了C++中QSObject::put方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::put方法的具体用法?C++ QSObject::put怎么用?C++ QSObject::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setVar
bool Debugger::setVar(const QString &ident, const QSObject &value)
{
if (!eng || ident == QString::fromLatin1("this"))
return false;
int dot = ident.find('.');
QString sub = dot > 0 ? ident.mid(0, dot) : ident;
QSObject base;
// resolve base
if (sub == QString::fromLatin1("||Global||")) {
base = env()->globalObject();
} else if (sub == QString::fromLatin1("||Activation||")) {
base = env()->currentScope();
} else if (sub == QString::fromLatin1("this")) {
base = env()->thisValue();
} else {
// return false;
ScopeChain::const_iterator it = env()->scope().begin();
for (it = env()->scope().begin(); it != env()->scope().end(); ++it) {
if ((*it).hasProperty(sub)) {
base = *it;
break;
}
}
if (it == env()->scope().end())
return false;
#if 0 // ###
const QSList *chain = Context::current()->pScopeChain();
QSListIterator scope = chain->begin();
while (scope != chain->end()) {
if (scope->hasProperty(sub)) {
base = *scope;
break;
}
scope++;
}
if (scope == chain->end())
return false;
#endif
}
// look up each part of a.b.c.
while (dot > 0) {
int olddot = dot;
dot = ident.find('.', olddot + 1);
if (dot < 0) {
sub = ident.mid(olddot + 1);
break;
}
sub = ident.mid(olddot + 1, dot - olddot - 1);
if (!base.hasProperty(sub))
return false;
base = base.get(sub);
}
base.put(sub, value);
return true;
}
示例2: test
QSObject QSRegExpClass::test( QSEnv *env )
{
QSObject obj = env->thisValue();
QRegExp *re = regExp( &obj );
QString s = env->arg( 0 ).toString();
uint length = s.length();
int i = obj.get( QString::fromLatin1("lastIndex") ).toInt32();
QSObject tmp = obj.get( QString::fromLatin1("global") );
if ( !tmp.toBoolean() )
i = 0;
if ( i < 0 || i >(int) length ) {
obj.put( QString::fromLatin1("lastIndex"), 0 );
return env->createBoolean( FALSE );
}
i = re->search( s, i );
obj.env()->regexpClass()->lastCaptures = re->capturedTexts();
return env->createBoolean( i >= 0 );
}