本文整理汇总了C++中QSObject::isFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::isFunction方法的具体用法?C++ QSObject::isFunction怎么用?C++ QSObject::isFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::isFunction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTransientSignalHandler
/*!
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
}
}
示例2: refScope
ScopeChain QSFuncRefClass::refScope( const QSObject &ref )
{
if( ref.isFunction() ) {
return ( (QSReferenceData*) ref.shVal() )->context;
}
qWarning( "QSFuncRefClass::refScope() - not a reference" );
return ScopeChain();
}
示例3: 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();
}
示例4: refMember
QSMember QSFuncRefClass::refMember( const QSObject &ref )
{
if( ref.isFunction() ) {
return ( (QSReferenceData*) ref.shVal() )->member;
}
qWarning( "QSFuncRefClass::refMember() - not a reference" );
return QSMember();
}
示例5: call
bool QSEngineImp::call( QSObject *scope, const QString &func,
const QSList &args )
{
init();
QSObject t;
if ( !scope || !scope->isValid() ) {
t = env()->globalObject();
scope = &t;
}
QSObject v = scope->getQualified(func);
Q_ASSERT(v.isValid());
if ( !v.isDefined() ) {
if (func != QString::fromLatin1("main")) {
errType = ReferenceError;
errMsgs.append( QString::fromLatin1("Unknown function: ") + func );
errLines.append( 0 );
}
return false;
}
if ( !v.isFunction() ) {
errType = TypeError;
errMsgs.append( func + QString::fromLatin1(" is not a function. Call failed.") );
errLines.append( 0 );
return false;
}
QSObject res = v.invoke( QSMember(), args );
if ( env()->isExceptionMode() ) {
QSObject err = env()->exception();
errType = 99; /* TODO */
errLines.append(QSErrorClass::errorLine(&err));
errMsgs.append(QSErrorClass::errorName(&err) + QString::fromLatin1(". ") + QSErrorClass::errorMessage(&err));
#ifdef QSDEBUGGER
if (dbg)
dbg->setSourceId(QSErrorClass::errorSourceId(&err));
#endif
env()->clearException();
return false;
} else {
errType = 0;
errLines.clear();
errMsgs.clear();
// return value
retVal = res;
return true;
}
}
示例6: timerEvent
void QuickInterpreter::timerEvent(QTimerEvent *e)
{
int id = e->timerId();
QSObject function = m_timers[id];
Q_ASSERT(function.isValid());
Q_ASSERT(function.isFunction());
QSList arguments;
arguments.append(env()->createNumber(id));
QSObject func_base = QSFuncRefClass::refBase(function);
QString func_name = QSFuncRefClass::refMember(function).name();
call(func_base, func_name, arguments);
}
示例7: qsStartTimer
/*******************************************************************************
* Timers
*/
QSObject qsStartTimer( QSEnv *env )
{
QSObject hnd = env->arg( 1 );
if ( hnd.isFunction() ) {
QuickInterpreter *ip = QuickInterpreter::fromEnv(env);
int interval = (int) env->arg(0).toNumber();
int id = ip->startTimer(interval);
QHash<int, QSObject> *timers = ip->timers();
timers->insert(id, hnd);
return env->createNumber(id);
}
QString msg = QString::fromLatin1("Can only install functions as event handler");
return env->throwError( TypeError, msg );
}