Qt 4.8
Public Functions | Properties | List of all members
QDeclarativeScriptString Class Reference

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

#include <qdeclarativescriptstring.h>

Public Functions

QDeclarativeContextcontext () const
 Returns the context for the script. More...
 
QDeclarativeScriptStringoperator= (const QDeclarativeScriptString &)
 Assigns other to this. More...
 
 QDeclarativeScriptString ()
 Constructs an empty instance. More...
 
 QDeclarativeScriptString (const QDeclarativeScriptString &)
 Copies other. More...
 
QObjectscopeObject () const
 Returns the scope object for the script. More...
 
QString script () const
 Returns the script text. More...
 
void setContext (QDeclarativeContext *)
 Sets the context for the script. More...
 
void setScopeObject (QObject *)
 Sets the scope object for the script. More...
 
void setScript (const QString &)
 Sets the script text. More...
 
 ~QDeclarativeScriptString ()
 

Properties

QSharedDataPointer< QDeclarativeScriptStringPrivated
 

Detailed Description

The QDeclarativeScriptString class encapsulates a script and its context.

Since
4.7

QDeclarativeScriptString 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)}

MyType {
script: myObj.value = Math.max(myValue, 100)
}

If instead the property had a type of QDeclarativeScriptString, 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 QDeclarativeExpression.

QDeclarativeExpression expr(scriptString.context(), scriptString.script(), scriptStr.scopeObject());
expr.value();
See also
QDeclarativeExpression

Definition at line 58 of file qdeclarativescriptstring.h.

Constructors and Destructors

◆ QDeclarativeScriptString() [1/2]

QDeclarativeScriptString::QDeclarativeScriptString ( )

Constructs an empty instance.

Definition at line 91 of file qdeclarativescriptstring.cpp.

93 {
94 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ QDeclarativeScriptString() [2/2]

QDeclarativeScriptString::QDeclarativeScriptString ( const QDeclarativeScriptString other)

Copies other.

Definition at line 99 of file qdeclarativescriptstring.cpp.

100 : d(other.d)
101 {
102 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ ~QDeclarativeScriptString()

QDeclarativeScriptString::~QDeclarativeScriptString ( )
Warning
This function is not part of the public interface.

Definition at line 107 of file qdeclarativescriptstring.cpp.

108 {
109 }

Functions

◆ context()

QDeclarativeContext * QDeclarativeScriptString::context ( ) const

Returns the context for the script.

Definition at line 123 of file qdeclarativescriptstring.cpp.

Referenced by QDeclarativeScriptActionPrivate::execute(), and setContext().

124 {
125  return d->context;
126 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ operator=()

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

Assigns other to this.

Definition at line 114 of file qdeclarativescriptstring.cpp.

115 {
116  d = other.d;
117  return *this;
118 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ scopeObject()

QObject * QDeclarativeScriptString::scopeObject ( ) const

Returns the scope object for the script.

Definition at line 139 of file qdeclarativescriptstring.cpp.

Referenced by QDeclarativeScriptActionPrivate::execute().

140 {
141  return d->scope;
142 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ script()

QString QDeclarativeScriptString::script ( ) const

◆ setContext()

void QDeclarativeScriptString::setContext ( QDeclarativeContext context)

Sets the context for the script.

Definition at line 131 of file qdeclarativescriptstring.cpp.

132 {
133  d->context = context;
134 }
QDeclarativeContext * context() const
Returns the context for the script.
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ setScopeObject()

void QDeclarativeScriptString::setScopeObject ( QObject object)

Sets the scope object for the script.

Definition at line 147 of file qdeclarativescriptstring.cpp.

148 {
149  d->scope = object;
150 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d

◆ setScript()

void QDeclarativeScriptString::setScript ( const QString script)

Sets the script text.

Definition at line 163 of file qdeclarativescriptstring.cpp.

164 {
165  d->script = script;
166 }
QSharedDataPointer< QDeclarativeScriptStringPrivate > d
QString script() const
Returns the script text.

Properties

◆ d

QSharedDataPointer<QDeclarativeScriptStringPrivate> QDeclarativeScriptString::d
private

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