![]() |
Qt 6.x
The Qt SDK
|
The QQmlScriptString class encapsulates a script and its context. More...
#include <qqmlscriptstring.h>
Public Member Functions | |
QQmlScriptString () | |
Constructs an empty instance. | |
QQmlScriptString (const QQmlScriptString &) | |
Copies other. | |
~QQmlScriptString () | |
QQmlScriptString & | operator= (const QQmlScriptString &) |
Assigns other to this. | |
bool | operator== (const QQmlScriptString &) const |
Returns true if this and the other QQmlScriptString objects are equal. | |
bool | operator!= (const QQmlScriptString &) const |
Returns true if this and the other QQmlScriptString objects are different. | |
bool | isEmpty () const |
Returns whether the QQmlScriptString is empty. | |
bool | isUndefinedLiteral () const |
Returns whether the content of the QQmlScriptString is the undefined literal. | |
bool | isNullLiteral () const |
Returns whether the content of the QQmlScriptString is the null literal. | |
QString | stringLiteral () const |
If the content of the QQmlScriptString is a string literal, returns that string. | |
qreal | numberLiteral (bool *ok) const |
If the content of the QQmlScriptString is a number literal, returns that number and sets ok to true. | |
bool | booleanLiteral (bool *ok) const |
If the content of the QQmlScriptString is a boolean literal, returns the boolean value and sets ok to true. | |
Friends | |
class | QQmlObjectCreator |
class | QQmlScriptStringPrivate |
class | QQmlExpression |
class | QQmlBinding |
class | QQmlPropertyBinding |
struct | QV4::QObjectWrapper |
The QQmlScriptString class encapsulates a script and its context.
\inmodule QtQml
QQmlScriptString is used to create QObject properties that accept a script "assignment" from QML.
Normally, the following QML would result in a binding being established for the script
property; i.e. script
would be assigned the value obtained from running {myObj.value
= Math.max(myValue, 100)}
\qml MyType { script: myObj.value = Math.max(myValue, 100) } \endqml
If instead the property had a type of QQmlScriptString, the script itself – {myObj.value = Math.max(myValue, 100)} – would be passed to the script
property and the class could choose how to handle it. Typically, the class will evaluate the script at some later time using a QQmlExpression.
Definition at line 23 of file qqmlscriptstring.h.
QQmlScriptString::QQmlScriptString | ( | ) |
Constructs an empty instance.
Definition at line 46 of file qqmlscriptstring.cpp.
QQmlScriptString::QQmlScriptString | ( | const QQmlScriptString & | other | ) |
Copies other.
Definition at line 65 of file qqmlscriptstring.cpp.
QQmlScriptString::~QQmlScriptString | ( | ) |
Definition at line 73 of file qqmlscriptstring.cpp.
bool QQmlScriptString::booleanLiteral | ( | bool * | ok | ) | const |
If the content of the QQmlScriptString is a boolean literal, returns the boolean value and sets ok to true.
Otherwise returns false and sets ok to false.
Definition at line 180 of file qqmlscriptstring.cpp.
References ok, and QQmlScriptStringPrivate::script.
bool QQmlScriptString::isEmpty | ( | ) | const |
Returns whether the QQmlScriptString is empty.
Definition at line 129 of file qqmlscriptstring.cpp.
References QQmlScriptStringPrivate::bindingId, QString::isEmpty(), and QQmlScriptStringPrivate::script.
Referenced by QQuickScriptActionPrivate::debugAction(), and QQuickScriptActionPrivate::execute().
bool QQmlScriptString::isNullLiteral | ( | ) | const |
Returns whether the content of the QQmlScriptString is the null
literal.
Definition at line 149 of file qqmlscriptstring.cpp.
References QQmlScriptStringPrivate::script.
bool QQmlScriptString::isUndefinedLiteral | ( | ) | const |
Returns whether the content of the QQmlScriptString is the undefined
literal.
Definition at line 141 of file qqmlscriptstring.cpp.
References QQmlScriptStringPrivate::script.
Referenced by QQuickAnchorSet::setBaseline(), QQuickAnchorSet::setBottom(), QQuickAnchorSet::setHorizontalCenter(), QQuickAnchorSet::setLeft(), QQuickAnchorSet::setRight(), QQuickAnchorSet::setTop(), and QQuickAnchorSet::setVerticalCenter().
qreal QQmlScriptString::numberLiteral | ( | bool * | ok | ) | const |
If the content of the QQmlScriptString is a number literal, returns that number and sets ok to true.
Otherwise returns 0.0 and sets ok to false.
Definition at line 169 of file qqmlscriptstring.cpp.
References QQmlScriptStringPrivate::isNumberLiteral, QQmlScriptStringPrivate::numberValue, and ok.
bool QQmlScriptString::operator!= | ( | const QQmlScriptString & | other | ) | const |
Returns true
if this and the other QQmlScriptString objects are different.
Definition at line 121 of file qqmlscriptstring.cpp.
References operator==(), and other().
QQmlScriptString & QQmlScriptString::operator= | ( | const QQmlScriptString & | other | ) |
Assigns other to this.
Definition at line 80 of file qqmlscriptstring.cpp.
References other().
bool QQmlScriptString::operator== | ( | const QQmlScriptString & | other | ) | const |
Returns true
if this and the other QQmlScriptString objects are equal.
Definition at line 91 of file qqmlscriptstring.cpp.
References QQmlScriptStringPrivate::bindingId, QQmlScriptStringPrivate::context, QQmlScriptStringPrivate::isNumberLiteral, QQmlScriptStringPrivate::isStringLiteral, QQmlScriptStringPrivate::numberValue, other(), QQmlScriptStringPrivate::scope, and QQmlScriptStringPrivate::script.
Referenced by operator!=().
QString QQmlScriptString::stringLiteral | ( | ) | const |
If the content of the QQmlScriptString is a string literal, returns that string.
Otherwise returns a null QString.
Definition at line 158 of file qqmlscriptstring.cpp.
References QQmlScriptStringPrivate::isStringLiteral, QString::mid(), QQmlScriptStringPrivate::script, and QString::size().
|
friend |
Definition at line 52 of file qqmlscriptstring.h.
|
friend |
Definition at line 51 of file qqmlscriptstring.h.
|
friend |
Definition at line 49 of file qqmlscriptstring.h.
|
friend |
Definition at line 53 of file qqmlscriptstring.h.
|
friend |
Definition at line 50 of file qqmlscriptstring.h.
|
friend |
Definition at line 54 of file qqmlscriptstring.h.