本文整理汇总了C++中QSObject类的典型用法代码示例。如果您正苦于以下问题:C++ QSObject类的具体用法?C++ QSObject怎么用?C++ QSObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arg
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() );
}
示例2:
/*!
Returns the current execution context of the interpreter. This is
either a QObject pointer or 0.
*/
QObject *QSInterpreter::currentContext() const
{
QSObject o = d->interpreter->env()->currentScope();
if (o.isA(d->interpreter->wrapperClass()))
return d->interpreter->wrapperClass()->shared(&o)->objects[0];
return 0;
}
示例3: env
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();
}
示例4: qsa_slot_callback
void qsa_slot_callback(QObject *_this, int callId, int paramCount,
const QMetaType::Type *types,
const QByteArray *typeNames,
void *argumentList[])
{
// printf("qsa_slot_callback, id=%d\n", callId);
QuickInterpreter *ip = static_cast<QuickInterpreter *>(_this);
QSAConnection connection = ip->scriptSlot(callId);
Q_ASSERT(connection.sender);
Q_ASSERT(connection.signal.length());
Q_ASSERT(connection.function_ref.isValid());
QSEnv *env = ip->env();
QSList arguments;
for (int i=1; i<paramCount; ++i) {
QSATypeInfo info;
info.name = typeNames[i];
info.id = types[i];
QSObject val = convert_qt2qsa(env, argumentList[i], info, _this);
Q_ASSERT(val.isValid());
arguments.append(val);
}
QSObject func_base = QSFuncRefClass::refBase(connection.function_ref);
QString func_name = QSFuncRefClass::refMember(connection.function_ref).name();
ip->call(func_base, func_name, arguments);
}
示例5: qtscriptFunction
/*!
Adds the Qt Script function \a qtscriptFunction (fully qualified)
as a transient signal handler for the C++ signal \a signal of the
object \a sender.
Example:
\code
interpreter->addTransientSignalHandler( myButton, SIGNAL( clicked() ), "classA.obj.calculate" );
\endcode
\sa removeTransientSignalHandler()
*/
void QSInterpreter::addTransientSignalHandler(QObject *sender,
const char *signal,
const char *qtscriptFunction)
{
QuickInterpreter *ip = interpreter();
QString func = QString::fromLatin1(qtscriptFunction);
func.left(func.find('('));
QSObject senderObj = ip->wrap(sender);
QSObject obj = ip->object(func);
if (!obj.isFunction()) {
qDebug("QSInterpreter::addTransientSignalHandler(): '%s' not a function",
qtscriptFunction);
return;
}
QSObject base = QSFuncRefClass::refBase(obj);
QSMember member = QSFuncRefClass::refMember(obj);
QSWrapperShared *sh = ip->wrapperClass()->shared(&senderObj);
if (!sh->setEventHandler(ip, QString::fromLatin1(signal + 1), 0, member.name(), base)) {
#if defined( QT_CHECK_STATE )
qWarning("QSInterpreter::addTransientSignalHandler(), "
"failed to add signal handler: '%s' to '%s'", signal + 1, qtscriptFunction);
#endif
}
}
示例6: vTypeToQSType
QSObject QSAEditor::queryQSObject( const QMetaObject *meta, const QString &property, bool /*includeSuperClass*/ ) const
{
int propertyIndex = -1;
const QMetaObject *m = meta;
propertyIndex = m->indexOfProperty(property.toLatin1().constData());
if (propertyIndex >= 0) {
QMetaProperty mp = m->property(propertyIndex);
QSObject o = vTypeToQSType( QString::fromLatin1(mp.typeName()) );
if ( !o.isNull() && !o.isUndefined() )
return o;
}
m = meta;
for (int i=0; i<m->methodCount(); ++i) {
QMetaMethod mm = m->method(i);
if (mm.methodType() == QMetaMethod::Slot) {
QString n = QLatin1String(mm.methodSignature());
n = n.left(n.indexOf('('));
if ( property != n )
continue;
return vTypeToQSType(mm.typeName());
}
}
return env()->createUndefined();
}
示例7: arg
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;
}
示例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: write
void QSRegExpClass::write(QSObject *objPtr, const QSMember &mem,
const QSObject &val ) const
{
if (mem.type() != QSMember::Custom) {
QSWritableClass::write(objPtr, mem, val);
return;
}
Q_ASSERT(objPtr->objectType() == objPtr->objectType()->env()->regexpClass());
switch (mem.index()) {
case Source:
((QSRegExpShared*)objPtr->shVal())->source = val.toString();
break;
case Global:
((QSRegExpShared*)objPtr->shVal())->global = val.toBoolean();
break;
case IgnoreCase:
{
bool ic = val.toBoolean();
((QSRegExpShared*)objPtr->shVal())->ignoreCase = ic;
((QSRegExpShared*)objPtr->shVal())->reg.setCaseSensitive(!ic);
}
break;
default:
QSWritableClass::write(objPtr, mem, val);
}
}
示例10: 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;
}
示例11: refMember
QSMember QSFuncRefClass::refMember( const QSObject &ref )
{
if( ref.isFunction() ) {
return ( (QSReferenceData*) ref.shVal() )->member;
}
qWarning( "QSFuncRefClass::refMember() - not a reference" );
return QSMember();
}
示例12: refScope
ScopeChain QSFuncRefClass::refScope( const QSObject &ref )
{
if( ref.isFunction() ) {
return ( (QSReferenceData*) ref.shVal() )->context;
}
qWarning( "QSFuncRefClass::refScope() - not a reference" );
return ScopeChain();
}
示例13: refBase
QSObject QSFuncRefClass::refBase( const QSObject &ref )
{
if( ref.isFunction() ) {
return ( (QSReferenceData*) ref.shVal() )->base;
}
qWarning( "QSFuncRefClass::refBase() - not a reference" );
return ref.env()->createUndefined();
}
示例14: 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;
}
示例15: 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() );
}