QScriptString Class

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

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

Public Functions

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

Detailed Description

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

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 using QScriptClass to implement array-like objects.

Member Function Documentation

QScriptString::QScriptString()

Constructs an invalid QScriptString.

QScriptString::QScriptString(const QScriptString &other)

Constructs a new QScriptString that is a copy of other.

QScriptString::~QScriptString()

Destroys this QScriptString.

bool QScriptString::isValid() const

Returns true if this 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.

This function was introduced in Qt 4.6.

QString QScriptString::toString() const

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

See also isValid().

QString QScriptString::operator QString() const

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

See also toString().

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

Returns true if this QScriptString is not equal to other; otherwise returns false.

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

Assigns the other value to this QScriptString.

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

Returns true if this QScriptString is equal to other; otherwise returns false.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support