📄 qscriptvalue.cpp
字号:
\sa isQMetaObject()*/const QMetaObject *QScriptValue::toQMetaObject() const{ return QScriptValuePrivate::valueOf(*this).toQMetaObject();}/*! Sets the value of this QScriptValue's property with the given \a name to the given \a value. If this QScriptValue is not an object, this function does nothing. If this QScriptValue does not already have a property with name \a name, a new property is created; the given \a flags then specify how this property may be accessed by script code. If \a value is invalid, the property is removed. If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling setProperty() has side-effects on the script engine, since the setter function will be called with the given \a value as argument (possibly resulting in an uncaught script exception). Note that you cannot specify custom getter or setter functions for built-in properties, such as the \c{length} property of Array objects or meta properties of QObject objects. \sa property()*/void QScriptValue::setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags){ if (isValid() && value.isValid() && (value.engine() != engine())) { qWarning("QScriptValue::setProperty(%s) failed: " "cannot set value created in a different engine", qPrintable(name)); return; } QScriptValuePrivate::valueOf(*this).setProperty(name, QScriptValuePrivate::valueOf(value), flags);}/*! Returns the value of this QScriptValue's property with the given \a name, using the given \a mode to resolve the property. If no such property exists, an invalid QScriptValue is returned. If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling property() has side-effects on the script engine, since the getter function will be called (possibly resulting in an uncaught script exception). If an exception occurred, property() returns the value that was thrown (typically an \c{Error} object). \sa setProperty(), propertyFlags()*/QScriptValue QScriptValue::property(const QString &name, const ResolveFlags &mode) const{ return QScriptValuePrivate::valueOf(*this).property(name, mode);}/*! \overload Returns the property at the given \a arrayIndex, using the given \a mode to resolve the property. This function is provided for convenience and performance when working with array objects. If this QScriptValue is not an Array object, this function behaves as if property() was called with the string representation of \a arrayIndex.*/QScriptValue QScriptValue::property(quint32 arrayIndex, const ResolveFlags &mode) const{ return QScriptValuePrivate::valueOf(*this).property(arrayIndex, mode);}/*! \overload Sets the property at the given \a arrayIndex to the given \a value. This function is provided for convenience and performance when working with array objects. If this QScriptValue is not an Array object, this function behaves as if setProperty() was called with the string representation of \a arrayIndex.*/void QScriptValue::setProperty(quint32 arrayIndex, const QScriptValue &value, const PropertyFlags &flags){ if (isValid() && value.isValid() && (value.engine() != engine())) { qWarning("QScriptValue::setProperty() failed: " "cannot set value created in a different engine"); return; } QScriptValuePrivate::valueOf(*this).setProperty(arrayIndex, QScriptValuePrivate::valueOf(value), flags);}/*! Returns the flags of the property with the given \a name, using the given \a mode to resolve the property. \sa property()*/QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QString &name, const ResolveFlags &mode) const{ return QScriptValuePrivate::valueOf(*this).propertyFlags(name, mode);}/*! Calls this QScriptValue as a function, using \a thisObject as the `this' object in the function call, and passing \a args as arguments to the function. Returns the value returned from the function. If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue. Note that if \a thisObject is not an object, the global object (see \l{QScriptEngine::globalObject()}) will be used as the `this' object. Calling call() can cause an exception to occur in the script engine; in that case, call() returns the value that was thrown (typically an \c{Error} object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred. \sa construct()*/QScriptValue QScriptValue::call(const QScriptValue &thisObject, const QScriptValueList &args){ if (isFunction() && thisObject.isValid() && (thisObject.engine() != engine())) { qWarning("QScriptValue::call() failed: " "cannot call function with thisObject created in " "a different engine"); return QScriptValue(); } return QScriptValuePrivate::valueOf(*this).call(QScriptValuePrivate::valueOf(thisObject), QScriptValuePrivate::toImplList(args));}/*! Calls this QScriptValue as a function, using \a thisObject as the `this' object in the function call, and passing \a arguments as arguments to the function. Returns the value returned from the function. If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue. \a arguments can be an arguments object, an array, null or undefined; any other type will cause a TypeError to be thrown. Note that if \a thisObject is not an object, the global object (see \l{QScriptEngine::globalObject()}) will be used as the `this' object. \sa construct(), QScriptContext::argumentsObject()*/QScriptValue QScriptValue::call(const QScriptValue &thisObject, const QScriptValue &arguments){ if (isFunction() && thisObject.isValid() && (thisObject.engine() != engine())) { qWarning("QScriptValue::call() failed: " "cannot call function with thisObject created in " "a different engine"); return QScriptValue(); } return QScriptValuePrivate::valueOf(*this).call(QScriptValuePrivate::valueOf(thisObject), QScriptValuePrivate::valueOf(arguments));}/*! Creates a new \c{Object} and calls this QScriptValue as a constructor, using the created object as the `this' object and passing \a args as arguments. If the return value from the constructor call is an object, then that object is returned; otherwise the created object is returned. If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue. \a args can be an arguments object, an array, null or undefined; any other type will cause a TypeError to be thrown. Calling construct() can cause an exception to occur in the script engine; in that case, construct() returns the value that was thrown (typically an \c{Error} object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred. \sa call(), QScriptEngine::newObject()*/QScriptValue QScriptValue::construct(const QScriptValueList &args){ return QScriptValuePrivate::valueOf(*this).construct(QScriptValuePrivate::toImplList(args));}/*! Creates a new \c{Object} and calls this QScriptValue as a constructor, using the created object as the `this' object and passing \a arguments as arguments. If the return value from the constructor call is an object, then that object is returned; otherwise the created object is returned. If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue. \a arguments can be an arguments object, an array, null or undefined. Any other type will cause a TypeError to be thrown. \sa call(), QScriptEngine::newObject(), QScriptContext::argumentsObject()*/QScriptValue QScriptValue::construct(const QScriptValue &arguments){ return QScriptValuePrivate::valueOf(*this).construct(QScriptValuePrivate::valueOf(arguments));}/*! Returns the QScriptEngine that created this QScriptValue, or 0 if this QScriptValue is invalid.*/QScriptEngine *QScriptValue::engine() const{ return QScriptValuePrivate::valueOf(*this).engine();}/*! Returns true if this QScriptValue is of the primitive type Boolean; otherwise returns false. \sa toBoolean()*/bool QScriptValue::isBoolean() const{ return QScriptValuePrivate::valueOf(*this).isBoolean();}/*! Returns true if this QScriptValue is of the primitive type Number; otherwise returns false. \sa toNumber()*/bool QScriptValue::isNumber() const{ return QScriptValuePrivate::valueOf(*this).isNumber();}/*! Returns true if this QScriptValue is of the primitive type String; otherwise returns false. \sa toString()*/bool QScriptValue::isString() const{ return QScriptValuePrivate::valueOf(*this).isString();}/*! Returns true if this QScriptValue is a function; otherwise returns false. \sa call()*/bool QScriptValue::isFunction() const{ return QScriptValuePrivate::valueOf(*this).isFunction();}/*! Returns true if this QScriptValue is of the primitive type Null; otherwise returns false. \sa QScriptEngine::nullValue()*/bool QScriptValue::isNull() const{ return QScriptValuePrivate::valueOf(*this).isNull();}/*! Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false. \sa QScriptEngine::undefinedValue()*/bool QScriptValue::isUndefined() const{ return QScriptValuePrivate::valueOf(*this).isUndefined();}/*! Returns true if this QScriptValue is of the Object type; otherwise returns false. Note that function values, variant values, and QObject values are objects, so this function returns true for such values. \sa toObject(), QScriptEngine::newObject()*/bool QScriptValue::isObject() const{ return QScriptValuePrivate::valueOf(*this).isObject();}/*! Returns true if this QScriptValue is a variant value; otherwise returns false. \sa toVariant(), QScriptEngine::newVariant()*/bool QScriptValue::isVariant() const{ return QScriptValuePrivate::valueOf(*this).isVariant();}/*! Returns true if this QScriptValue is a QObject; otherwise returns false. Note: This function returns true even if the QObject that this QScriptValue wraps has been deleted. \sa toQObject(), QScriptEngine::newQObject()*/bool QScriptValue::isQObject() const{ return QScriptValuePrivate::valueOf(*this).isQObject();}/*! Returns true if this QScriptValue is a QMetaObject; otherwise returns false. \sa toQMetaObject(), QScriptEngine::newQMetaObject()*/bool QScriptValue::isQMetaObject() const{ return QScriptValuePrivate::valueOf(*this).isQMetaObject();}/*! Returns true if this QScriptValue is valid; otherwise returns false.*/bool QScriptValue::isValid() const{ return QScriptValuePrivate::valueOf(*this).isValid();}#endif // QT_NO_SCRIPT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -