本文整理汇总了C++中QScriptValueImpl::isFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl::isFunction方法的具体用法?C++ QScriptValueImpl::isFunction怎么用?C++ QScriptValueImpl::isFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueImpl
的用法示例。
在下文中一共展示了QScriptValueImpl::isFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method_defineSetter
QScriptValueImpl Object::method_defineSetter(QScriptContextPrivate *context, QScriptEnginePrivate *eng,
QScriptClassInfo *)
{
QString propertyName = context->argument(0).toString();
if (context->thisObject().propertyFlags(propertyName) & QScriptValue::ReadOnly)
return context->throwError(QLatin1String("cannot redefine read-only property"));
QScriptValueImpl setter = context->argument(1);
if (!setter.isFunction())
return context->throwError(QLatin1String("setter must be a function"));
context->thisObject().setProperty(propertyName, setter, QScriptValue::PropertySetter);
return eng->undefinedValue();
}
示例2: method_connect
QScriptValueImpl Function::method_connect(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
Q_UNUSED(classInfo);
#ifndef QT_NO_QOBJECT
if (context->argumentCount() == 0) {
return context->throwError(
QLatin1String("Function.prototype.connect: no arguments given"));
}
QScriptValueImpl self = context->thisObject();
QScriptFunction *fun = self.toFunction();
if ((fun == 0) || (fun->type() != QScriptFunction::Qt)) {
return context->throwError(
QScriptContext::TypeError,
QLatin1String("Function.prototype.connect: this object is not a signal"));
}
QtFunction *qtSignal = static_cast<QtFunction*>(fun);
const QMetaObject *meta = qtSignal->metaObject();
if (!meta) {
return context->throwError(
QScriptContext::TypeError,
QString::fromLatin1("Function.prototype.connect: cannot connect to deleted QObject"));
}
QMetaMethod sig = meta->method(qtSignal->initialIndex());
if (sig.methodType() != QMetaMethod::Signal) {
return context->throwError(QScriptContext::TypeError,
QString::fromLatin1("Function.prototype.connect: %0::%1 is not a signal")
.arg(QLatin1String(qtSignal->metaObject()->className()))
.arg(QLatin1String(sig.signature())));
}
QScriptValueImpl receiver;
QScriptValueImpl slot;
QScriptValueImpl arg0 = context->argument(0);
if (context->argumentCount() < 2) {
receiver = QScriptValueImpl();
slot = arg0;
} else {
receiver = arg0;
QScriptValueImpl arg1 = context->argument(1);
if (arg1.isFunction())
slot = arg1;
else
slot = receiver.property(arg1.toString(), QScriptValue::ResolvePrototype);
}
if (!slot.isFunction()) {
return context->throwError(
QScriptContext::TypeError,
QLatin1String("Function.prototype.connect: target is not a function"));
}
bool ok = eng->scriptConnect(self, receiver, slot);
if (!ok) {
return context->throwError(
QString::fromLatin1("Function.prototype.connect: failed to connect to %0::%1")
.arg(QLatin1String(qtSignal->metaObject()->className()))
.arg(QLatin1String(sig.signature())));
}
return eng->undefinedValue();
#else
Q_UNUSED(eng);
Q_UNUSED(classInfo);
return context->throwError(QScriptContext::TypeError,
QLatin1String("Function.prototype.connect"));
#endif // QT_NO_QOBJECT
}