Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlScriptString Class Reference

The QQmlScriptString class encapsulates a script and its context. More...

#include <qqmlscriptstring.h>

+ Collaboration diagram for QQmlScriptString:

Public Member Functions

 QQmlScriptString ()
 Constructs an empty instance.
 
 QQmlScriptString (const QQmlScriptString &)
 Copies other.
 
 ~QQmlScriptString ()
 
QQmlScriptStringoperator= (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
 

Detailed Description

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.

QQmlExpression expr(scriptString);
expr.evaluate();
The QQmlExpression class evaluates JavaScript in a QML context.
See also
QQmlExpression

Definition at line 23 of file qqmlscriptstring.h.

Constructor & Destructor Documentation

◆ QQmlScriptString() [1/2]

QQmlScriptString::QQmlScriptString ( )

Constructs an empty instance.

Definition at line 46 of file qqmlscriptstring.cpp.

◆ QQmlScriptString() [2/2]

QQmlScriptString::QQmlScriptString ( const QQmlScriptString & other)

Copies other.

Definition at line 65 of file qqmlscriptstring.cpp.

◆ ~QQmlScriptString()

QQmlScriptString::~QQmlScriptString ( )

Definition at line 73 of file qqmlscriptstring.cpp.

Member Function Documentation

◆ booleanLiteral()

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.

◆ isEmpty()

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.

+ Here is the call graph for this function:

◆ isNullLiteral()

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.

◆ isUndefinedLiteral()

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

+ Here is the caller graph for this function:

◆ numberLiteral()

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.

Referenced by QQuickParentChange::actions().

+ Here is the caller graph for this function:

◆ operator!=()

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

Returns true if this and the other QQmlScriptString objects are different.

See also
operator==()

Definition at line 121 of file qqmlscriptstring.cpp.

References operator==(), and other().

+ Here is the call graph for this function:

◆ operator=()

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

Assigns other to this.

Definition at line 80 of file qqmlscriptstring.cpp.

References other().

+ Here is the call graph for this function:

◆ operator==()

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

Returns true if this and the other QQmlScriptString objects are equal.

See also
operator!=()

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stringLiteral()

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

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QQmlBinding

friend class QQmlBinding
friend

Definition at line 51 of file qqmlscriptstring.h.

◆ QQmlExpression

friend class QQmlExpression
friend

Definition at line 50 of file qqmlscriptstring.h.

◆ QQmlObjectCreator

friend class QQmlObjectCreator
friend

Definition at line 48 of file qqmlscriptstring.h.

◆ QQmlPropertyBinding

friend class QQmlPropertyBinding
friend

Definition at line 52 of file qqmlscriptstring.h.

◆ QQmlScriptStringPrivate

friend class QQmlScriptStringPrivate
friend

Definition at line 49 of file qqmlscriptstring.h.

◆ QV4::QObjectWrapper

friend struct QV4::QObjectWrapper
friend

Definition at line 53 of file qqmlscriptstring.h.


The documentation for this class was generated from the following files: