QScriptString Class Reference

[ QtScript module]

The QScriptString class acts as a handle to "interned" strings 在 QScriptEngine . 更多...

方法

Special Methods


详细描述

The QScriptString class acts as a handle to "interned" strings 在 QScriptEngine .

QScriptString can be used to achieve faster (repeated) property getting/setting, and comparison of property names, of script 对象。

To get a QScriptString representation of a string, pass the string to QScriptEngine.toStringHandle (). The typical usage pattern is to register one or more pre-defined strings when setting up your script environment, then subsequently use the relevant QScriptString as argument to e.g. QScriptValue.property ().

Call the toString () function to obtain the string that a QScriptString represents.

Call the toArrayIndex () function to convert a QScriptString to an array index. This is useful when 使用 QScriptClass to implement array-like objects.


方法文档编制

QScriptString.__init__ ( self )

Constructs an invalid QScriptString .

QScriptString.__init__ ( self , QScriptString   other )

构造新 QScriptString that is a copy of other .

bool QScriptString.isValid ( self )

返回 true,若此 QScriptString is valid; otherwise returns false.

(int, bool  ok ) QScriptString.toArrayIndex ( self )

Attempts to convert this QScriptString QtScript array index, and returns the 结果。

If a conversion error occurs, * ok is set to false; otherwise * ok is set to true.

该函数在 Qt 4.6 引入。

QString QScriptString.toString ( self )

Returns the string that this QScriptString represents, or a null string 若此 QScriptString 不是 valid.

另请参阅 isValid ().

bool QScriptString.__eq__ ( self , QScriptString   other )

int QScriptString.__hash__ ( self )

bool QScriptString.__ne__ ( self , QScriptString   other )