本文整理汇总了C++中QSObject::objectType方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::objectType方法的具体用法?C++ QSObject::objectType怎么用?C++ QSObject::objectType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::objectType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vTypeToQSType
QSObject QSAEditor::vTypeToQSType( const QString &type ) const
{
QSObject qstype = env()->globalObject().get( type.mid( 1 ) );
if( qstype.objectType() && qstype.objectType()->valueType() == TypeClass ) {
return qstype;
}
QVariant::Type t = QVariant::nameToType( type.toLatin1().constData() );
switch ( t ) {
case QVariant::Time:
case QVariant::DateTime:
return env()->globalObject().get( QString::fromLatin1("Date") );
case QVariant::StringList:
case QVariant::List:
case QVariant::Map:
return env()->globalObject().get( QString::fromLatin1("Array") );
case QVariant::ByteArray:
return env()->globalObject().get( QString::fromLatin1("String") );
case QVariant::Int:
case QVariant::UInt:
case QVariant::Double:
return env()->globalObject().get( QString::fromLatin1("Number") );
case QVariant::Bool:
return env()->globalObject().get( QString::fromLatin1("Boolean") );
default:
break;
}
return env()->createUndefined();
}
示例2: o
QSClass *QSCheckData::typeInfo( const QString &name ) const
{
QSMember member;
QSScopeResolutionList::const_iterator it = scopeStack.begin();
QSObject tmp;
tmp.setVal( (int) 0 );
int offset;
while( it!=scopeStack.end() ) {
offset = 0;
tmp.setType( (*it).cl );
const QSClass *cl;
if( (*it).cl->name() == QString::fromLatin1("QObject") ) {
cl = env()->thisValue().resolveMember( name, &member, tmp.objectType(),
&offset );
} else {
cl = tmp.resolveMember( name, &member, tmp.objectType(), &offset );
tmp.invalidate();
}
if( cl ) {
/* Avoid calls to deref for QSWrapperClass, when tmp is destroyed */
tmp.invalidate();
QSObject o( cl->fetchValue( 0, member ) );
if ( o.objectType() == env()->typeClass() )
return QSTypeClass::classValue(&o);
else
return 0;
}
it++;
}
return 0;
}
示例3: isEqual
QSEqualsResult QSFuncRefClass::isEqual( const QSObject &a, const QSObject &b ) const
{
if( a.objectType() == b.objectType() )
return ( QSEqualsResult )
( refBase( a ).equals( refBase( b ) )
&& refMember( a ) == refMember( b ) );
return EqualsNotEqual;
}
示例4: save
void QSPixmapClass::save( QSEnv *env )
{
if ( env->numArgs() < 1 || env->numArgs() > 2 ) {
env->throwError( QString::fromLatin1( "Pixmap.save() called with %1 arguments. 1 or 2 argument expected." ).
arg( env->numArgs() ) );
return;
}
QSObject t = env->thisValue();
QSPixmapClass *pac = (QSPixmapClass*)t.objectType();
QPixmap *pix = pac->pixmap( &t );
if ( !env->arg( 0 ).isString() ) {
env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. "
"Type String is expeced" ).
arg( env->arg( 0 ).typeName() ) );
return;
}
QString format = QFileInfo( env->arg( 0 ).toString() ).extension().upper();
QStrList l = QImageIO::outputFormats();
if ( l.find( format.latin1() ) == -1 )
format = QString::fromLatin1("PNG");
if ( env->numArgs() == 2 ) {
if ( !env->arg( 1 ).isString() ) {
env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. "
"as second argument. Type String is expeced" ).
arg( env->arg( 1 ).typeName() ) );
return;
}
format = env->arg( 1 ).toString();
}
pix->save( env->arg( 0 ).toString(), format.latin1() );
}
示例5: getQualified
QSObject QSObject::getQualified(const QString &name) const
{
QSObject obj = *this;
QString s = name;
// break up dotted notation ns like P1.P2.P3
while (!s.isEmpty()) {
int pos = s.find('.');
if (pos < 0)
pos = s.length();
// don't overwrite any existing objects, reuse them
QString cname = s.left(pos);
QSObject tmpobj = obj.get(cname);
// Search the class hieriarchy for member if undefined
if (!tmpobj.isDefined()) {
QSClass *base = obj.objectType()->base();
while (base && !tmpobj.isDefined()) {
tmpobj = base->get(&obj, cname);
base = base->base();
}
if (!tmpobj.isDefined())
return env()->createUndefined();
}
obj = tmpobj;
s = s.mid(pos + 1);
}
return obj;
}
示例6: resize
void QSPixmapClass::resize( QSEnv *env )
{
if ( env->numArgs() < 1 || env->numArgs() > 2 ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with %1 arguments. 1 or 2 arguments expected." ).
arg( env->numArgs() ) );
return;
}
QSObject t = env->thisValue();
QSPixmapClass *pac = (QSPixmapClass*)t.objectType();
QPixmap *pix = pac->pixmap( &t );
if ( env->numArgs() == 1 ) {
QSObject a0 = env->arg( 0 );
if ( !a0.isA( "Size" ) ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with an argument of type %1. "
"Type Size is expeced" ).
arg( a0.typeName() ) );
return;
}
pix->resize( *( (QSSizeClass*)a0.objectType() )->size( &a0 ) );
} else {
if ( !env->arg( 0 ).isA( "Number" ) || !env->arg( 1 ).isA( "Number" ) ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with arguments of type %1 and %2. "
"Type Number and Number is expeced" ).
arg( env->arg( 0 ).typeName() ).arg( env->arg( 1 ).typeName() ) );
return;
}
pix->resize( env->arg( 0 ).toInteger(), env->arg( 1 ).toInteger() );
}
return;
}
示例7: save
void QSPixmapClass::save( QSEnv *env )
{
if ( env->numArgs() < 1 || env->numArgs() > 2 ) {
env->throwError( QString::fromLatin1( "Pixmap.save() called with %1 arguments. 1 or 2 argument expected." ).
arg( env->numArgs() ) );
return;
}
QSObject t = env->thisValue();
QSPixmapClass *pac = (QSPixmapClass*)t.objectType();
QPixmap *pix = pac->pixmap( &t );
if ( !env->arg( 0 ).isString() ) {
env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. "
"Type String is expeced" ).
arg( env->arg( 0 ).typeName() ) );
return;
}
QString format = QFileInfo( env->arg( 0 ).toString() ).completeSuffix().toUpper();
QList<QByteArray> l = QImageWriter::supportedImageFormats();
if ( l.indexOf( format.toLatin1() ) == -1 )
format = QString::fromLatin1("PNG");
if ( env->numArgs() == 2 ) {
if ( !env->arg( 1 ).isString() ) {
env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. "
"as second argument. Type String is expeced" ).
arg( env->arg( 1 ).typeName() ) );
return;
}
format = env->arg( 1 ).toString();
}
pix->save( env->arg( 0 ).toString(), format.toLatin1().constData() );
}
示例8: normalize
QSObject QSRectClass::normalize(QSEnv *env)
{
QSObject t = env->thisValue();
QSRectClass *cl = (QSRectClass *)t.objectType();
QRect *r = cl->rect(&t);
return cl->construct(r->normalize());
}
示例9: isNull
QSObject QSPixmapClass::isNull( QSEnv *env )
{
QSObject t = env->thisValue();
QSPixmapClass *pac = (QSPixmapClass*)t.objectType();
QSObject result;
QPixmap *pix = pac->pixmap( &t );
return env->createBoolean( pix->isNull() );
}
示例10: functionsOf
QStringList QuickInterpreter::functionsOf(QSObject &obj, bool includeSignature, bool includeNative, bool includeMemberFunctions) const
{
const QSClass *objType = obj.objectType();
QSMemberMap mmap = objType == env()->typeClass() && includeMemberFunctions
? ((QSTypeClass*) objType)->allMembers(&obj)
: objType->members(&obj);
QMap<int, QString> functions;
for (QSMemberMap::Iterator it = mmap.begin(); it != mmap.end(); ++it) {
if (((*it).type() == QSMember::ScriptFunction ||
includeNative && ((*it).type() == QSMember::NativeFunction ||
(*it).type() == QSMember::NativeMemberFunction))
&& !(*it).isPrivate()) {
QString func = (*it).name();
// ### will break with mix of script and C++ functions
int idx = (*it).type() == QSMember::ScriptFunction ?
(*it).scriptFunction->index() : functions.size();
if (includeSignature) {
if ((*it).type() == QSMember::NativeFunction ||
(*it).type() == QSMember::NativeMemberFunction) {
func += QString::fromLatin1("()");
} else {
QSFunctionScopeClass *fsc = (*it).scriptFunction->scopeDefinition();
int args = fsc->numArguments();
func += QString::fromLatin1("(");
if (args > 0) {
func += QString::fromLatin1(" ");
QSMemberMap *members = fsc->definedMembers();
QVector<QString> vec(args);
for (QSMemberMap::ConstIterator ait = members->begin();
ait != members->end(); ++ait) {
if ((*ait).index() < args)
vec[ (*ait).index() ] = (*ait).name();
}
for (int i = 0; i < args; ++i) {
if (i > 0)
func += QString::fromLatin1(", ");
func += vec[i];
}
func += QString::fromLatin1(" ");
}
func += QString::fromLatin1(")");
}
}
functions[idx] = func;
}
}
// assemble to list sorted by original index
QStringList lst;
QMap<int, QString>::const_iterator cit = functions.begin();
for (; cit != functions.end(); ++cit)
lst << *cit;
return lst;
}
示例11: toStringScript
QSObject QSRegExpClass::toStringScript( QSEnv *env )
{
QSObject that = env->thisValue();
Q_ASSERT(that.objectType() == env->regexpClass());
QString pattern = QString::fromLatin1("/") + source(&that) + QString::fromLatin1("/");
if (isIgnoreCase(&that))
pattern += 'i';
if (isGlobal(&that))
pattern += 'g';
return env->createString(pattern);
}
示例12: hasMember
static bool hasMember(QSEnv *env, const QString &function, QSMember::Type type)
{
QSObject o = env->globalObject();
QSMember member;
QStringList names = function.split(QString::fromLatin1("."));
int nameCount = names.count();
for (QStringList::ConstIterator it = names.begin(); it != names.end(); ++it, --nameCount) {
if (nameCount==1) {
if (o.objectType() == env->typeClass())
return QSTypeClass::classValue(&o)->member(0, *it, &member)
&& member.type() == type;
else if (o.objectType()->member(&o, *it, &member))
return o.objectType()->member(0, *it, &member) && member.type() == type;
} else {
o = o.get(*it);
if (!o.isValid())
return false;
}
}
return false;
}
示例13: printScopeChain
void QSEnv::printScopeChain(const ScopeChain *chain)
{
QStringList lst;
ScopeChain::const_iterator it = chain->begin();
while (it != chain->end()) {
QSObject obj = *it;
QString tmp = !obj.isValid() ? QString::fromLatin1("#")
: obj.objectType()->identifier();
lst.append(tmp);
it++;
}
printf("Current scope is:: %s\n", lst.join(QString::fromLatin1(", ")).latin1());
}
示例14: resize
void QSPixmapClass::resize( QSEnv *env )
{
if ( env->numArgs() < 1 || env->numArgs() > 2 ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with %1 arguments. 1 or 2 arguments expected." ).
arg( env->numArgs() ) );
return;
}
QSObject t = env->thisValue();
QSPixmapClass *pac = (QSPixmapClass*)t.objectType();
QPixmap *pix = pac->pixmap( &t );
int w=-1;
int h=-1;
if ( env->numArgs() == 1 ) {
QSObject a0 = env->arg( 0 );
if ( !a0.isA( "Size" ) ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with an argument of type %1. "
"Type Size is expected" ).
arg( a0.typeName() ) );
return;
}
QSize size = *((QSSizeClass*)a0.objectType())->size(&a0);
w = size.width();
h = size.height();
} else {
if ( !env->arg( 0 ).isA( "Number" ) || !env->arg( 1 ).isA( "Number" ) ) {
env->throwError( QString::fromLatin1( "Pixmap.resize() called with arguments of type %1 and %2. "
"Type Number and Number is expected" ).
arg( env->arg( 0 ).typeName() ).arg( env->arg( 1 ).typeName() ) );
return;
}
w = env->arg( 0 ).toInteger();
h = env->arg( 1 ).toInteger();
}
if (w >= 0 && h >= 0) {
QPixmap tmppm(w, h);
tmppm.fill(Qt::black);
QPainter p(&tmppm);
p.drawPixmap(0, 0, *pix);
*pix = tmppm;
}
return;
}
示例15: convertToArgument
QSArgument QuickInterpreter::convertToArgument( const QSObject &o )
{
if( !o.isValid() )
return QSArgument();
const QSClass *cl = o.objectType();
if( cl->name() == QString::fromLatin1("QObject") ) {
QSWrapperShared *shared = (QSWrapperShared*) o.shVal();
if (shared->objects.isEmpty())
return QSArgument();
return QSArgument( shared->objects[0] );
} else if( cl == ptrClass ) {
Q_ASSERT( ptrClass->pointer( &o ) );
return QSArgument( ptrClass->pointer( &o ) );
} else {
return QSArgument( o.toVariant( QVariant::Invalid ) );
}
}