QScriptString Class

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

头: #include <QScriptString>
qmake: QT += script
Since: Qt 4.4

公共函数

QScriptString ()
QScriptString (const QScriptString & other )
~QScriptString ()
bool isValid () const
quint32 toArrayIndex (bool * ok = nullptr) const
QString toString () const
QString operator QString () const
bool operator!= (const QScriptString & other ) const
QScriptString & operator= (const QScriptString & other )
bool operator== (const QScriptString & other ) const

详细描述

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

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

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 ().

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

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

成员函数文档编制

QScriptString:: QScriptString ()

构造无效 QScriptString .

QScriptString:: QScriptString (const QScriptString & other )

构造新的 QScriptString that is a copy of other .

QScriptString:: ~QScriptString ()

销毁此 QScriptString .

bool QScriptString:: isValid () const

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

quint32 QScriptString:: toArrayIndex ( bool * ok = nullptr) const

Attempts to convert this QScriptString to a Qt Script array index, and returns the result.

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

该函数在 Qt 4.6 引入。

QString QScriptString:: toString () const

Returns the string that this QScriptString represents, or a null string if this QScriptString is not valid.

另请参阅 isValid ().

QString QScriptString:: operator QString () const

Returns the string that this QScriptString represents, or a null string if this QScriptString is not valid.

另请参阅 toString ().

bool QScriptString:: operator!= (const QScriptString & other ) const

返回 true,若此 QScriptString 不等于 other ;否则返回 false。

QScriptString &QScriptString:: operator= (const QScriptString & other )

赋值 other value to this QScriptString .

bool QScriptString:: operator== (const QScriptString & other ) const

返回 true,若此 QScriptString 等于 other ;否则返回 false。