[][src]Struct qt_qml::QQmlExpression

#[repr(C)]pub struct QQmlExpression { /* fields omitted */ }

For example, given a file main.qml like this:

C++ class: QQmlExpression.

C++ documentation:

For example, given a file main.qml like this:


  import QtQuick 2.0

  Item {
      width: 200; height: 200
  }

The following code evaluates a JavaScript expression in the context of the above QML:

QQmlEngine *engine = new QQmlEngine; QQmlComponent component(engine, QUrl::fromLocalFile("main.qml"));

QObject myObject = component.create(); QQmlExpression expr = new QQmlExpression(engine->rootContext(), myObject, "width * 2"); int result = expr->evaluate().toInt(); // result = 400

Methods

impl QQmlExpression[src]

pub fn value_changed(&self) -> Signal<()>[src]

Emitted each time the expression value changes from the last time it was evaluated. The expression must have been evaluated at least once (by calling QQmlExpression::evaluate()) before this signal will be emitted.

Returns a built-in Qt signal QQmlExpression::valueChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

Emitted each time the expression value changes from the last time it was evaluated. The expression must have been evaluated at least once (by calling QQmlExpression::evaluate()) before this signal will be emitted.

pub unsafe fn clear_error(&self)[src]

Clear any expression errors. Calls to hasError() following this will return false.

Calls C++ function: void QQmlExpression::clearError().

C++ documentation:

Clear any expression errors. Calls to hasError() following this will return false.

See also hasError() and error().

pub unsafe fn column_number(&self) -> c_int[src]

Returns the source file column number for this expression. The source location must have been previously set by calling setSourceLocation().

Calls C++ function: int QQmlExpression::columnNumber() const.

C++ documentation:

Returns the source file column number for this expression. The source location must have been previously set by calling setSourceLocation().

pub unsafe fn context(&self) -> QPtr<QQmlContext>[src]

Returns the QQmlContext this expression is associated with, or 0 if there is no association or the QQmlContext has been destroyed.

Calls C++ function: QQmlContext* QQmlExpression::context() const.

C++ documentation:

Returns the QQmlContext this expression is associated with, or 0 if there is no association or the QQmlContext has been destroyed.

pub unsafe fn engine(&self) -> QPtr<QQmlEngine>[src]

Returns the QQmlEngine this expression is associated with, or 0 if there is no association or the QQmlEngine has been destroyed.

Calls C++ function: QQmlEngine* QQmlExpression::engine() const.

C++ documentation:

Returns the QQmlEngine this expression is associated with, or 0 if there is no association or the QQmlEngine has been destroyed.

pub unsafe fn error(&self) -> CppBox<QQmlError>[src]

Return any error from the last call to evaluate(). If there was no error, this returns an invalid QQmlError instance.

Calls C++ function: QQmlError QQmlExpression::error() const.

C++ documentation:

Return any error from the last call to evaluate(). If there was no error, this returns an invalid QQmlError instance.

See also hasError() and clearError().

pub unsafe fn evaluate_1a(
    &self,
    value_is_undefined: *mut bool
) -> CppBox<QVariant>
[src]

Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expression is invalid or has an error.

Calls C++ function: QVariant QQmlExpression::evaluate(bool* valueIsUndefined = …).

C++ documentation:

Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expression is invalid or has an error.

valueIsUndefined is set to true if the expression resulted in an undefined value.

See also hasError() and error().

pub unsafe fn evaluate_0a(&self) -> CppBox<QVariant>[src]

Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expression is invalid or has an error.

Calls C++ function: QVariant QQmlExpression::evaluate().

C++ documentation:

Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expression is invalid or has an error.

valueIsUndefined is set to true if the expression resulted in an undefined value.

See also hasError() and error().

pub unsafe fn expression(&self) -> CppBox<QString>[src]

Returns the expression string.

Calls C++ function: QString QQmlExpression::expression() const.

C++ documentation:

Returns the expression string.

See also setExpression().

pub unsafe fn has_error(&self) -> bool[src]

Returns true if the last call to evaluate() resulted in an error, otherwise false.

Calls C++ function: bool QQmlExpression::hasError() const.

C++ documentation:

Returns true if the last call to evaluate() resulted in an error, otherwise false.

See also error() and clearError().

pub unsafe fn line_number(&self) -> c_int[src]

Returns the source file line number for this expression. The source location must have been previously set by calling setSourceLocation().

Calls C++ function: int QQmlExpression::lineNumber() const.

C++ documentation:

Returns the source file line number for this expression. The source location must have been previously set by calling setSourceLocation().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QQmlExpression::metaObject() const.

pub unsafe fn new() -> QBox<QQmlExpression>[src]

Create an invalid QQmlExpression.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression().

C++ documentation:

Create an invalid QQmlExpression.

As the expression will not have an associated QQmlContext, this will be a null expression object and its value will always be an invalid QVariant.

pub unsafe fn from_q_qml_context_q_object_q_string_q_object(
    arg1: impl CastInto<Ptr<QQmlContext>>,
    arg2: impl CastInto<Ptr<QObject>>,
    arg3: impl CastInto<Ref<QString>>,
    arg4: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlExpression>
[src]

Create a QQmlExpression object that is a child of parent.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression(QQmlContext* arg1, QObject* arg2, const QString& arg3, QObject* arg4 = …).

C++ documentation:

Create a QQmlExpression object that is a child of parent.

The expression JavaScript will be executed in the ctxt QQmlContext. If specified, the scope object's properties will also be in scope during the expression's execution.

pub unsafe fn from_q_qml_script_string_q_qml_context2_q_object(
    arg1: impl CastInto<Ref<QQmlScriptString>>,
    arg2: impl CastInto<Ptr<QQmlContext>>,
    arg3: impl CastInto<Ptr<QObject>>,
    arg4: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlExpression>
[src]

Create a QQmlExpression object that is a child of parent.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression(const QQmlScriptString& arg1, QQmlContext* arg2 = …, QObject* arg3 = …, QObject* arg4 = …).

C++ documentation:

Create a QQmlExpression object that is a child of parent.

The script provides the expression to be evaluated, the context to evaluate it in, and the scope object to evaluate it with. If provided, ctxt and scope will override the context and scope object provided by script.

See also QQmlScriptString.

pub unsafe fn from_q_qml_context_q_object_q_string(
    arg1: impl CastInto<Ptr<QQmlContext>>,
    arg2: impl CastInto<Ptr<QObject>>,
    arg3: impl CastInto<Ref<QString>>
) -> QBox<QQmlExpression>
[src]

Create a QQmlExpression object that is a child of parent.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression(QQmlContext* arg1, QObject* arg2, const QString& arg3).

C++ documentation:

Create a QQmlExpression object that is a child of parent.

The expression JavaScript will be executed in the ctxt QQmlContext. If specified, the scope object's properties will also be in scope during the expression's execution.

pub unsafe fn from_q_qml_script_string_q_qml_context_q_object(
    arg1: impl CastInto<Ref<QQmlScriptString>>,
    arg2: impl CastInto<Ptr<QQmlContext>>,
    arg3: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlExpression>
[src]

Create a QQmlExpression object that is a child of parent.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression(const QQmlScriptString& arg1, QQmlContext* arg2 = …, QObject* arg3 = …).

C++ documentation:

Create a QQmlExpression object that is a child of parent.

The script provides the expression to be evaluated, the context to evaluate it in, and the scope object to evaluate it with. If provided, ctxt and scope will override the context and scope object provided by script.

See also QQmlScriptString.

pub unsafe fn from_q_qml_script_string_q_qml_context(
    arg1: impl CastInto<Ref<QQmlScriptString>>,
    arg2: impl CastInto<Ptr<QQmlContext>>
) -> QBox<QQmlExpression>
[src]

Create a QQmlExpression object that is a child of parent.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression(const QQmlScriptString& arg1, QQmlContext* arg2 = …).

C++ documentation:

Create a QQmlExpression object that is a child of parent.

The script provides the expression to be evaluated, the context to evaluate it in, and the scope object to evaluate it with. If provided, ctxt and scope will override the context and scope object provided by script.

See also QQmlScriptString.

pub unsafe fn from_q_qml_script_string(
    arg1: impl CastInto<Ref<QQmlScriptString>>
) -> QBox<QQmlExpression>
[src]

Create a QQmlExpression object that is a child of parent.

Calls C++ function: [constructor] void QQmlExpression::QQmlExpression(const QQmlScriptString& arg1).

C++ documentation:

Create a QQmlExpression object that is a child of parent.

The script provides the expression to be evaluated, the context to evaluate it in, and the scope object to evaluate it with. If provided, ctxt and scope will override the context and scope object provided by script.

See also QQmlScriptString.

pub unsafe fn notify_on_value_changed(&self) -> bool[src]

Returns true if the valueChanged() signal is emitted when the expression's evaluated value changes.

Calls C++ function: bool QQmlExpression::notifyOnValueChanged() const.

C++ documentation:

Returns true if the valueChanged() signal is emitted when the expression's evaluated value changes.

See also setNotifyOnValueChanged().

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QQmlExpression::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QQmlExpression::qt_metacast(const char* arg1).

pub unsafe fn scope_object(&self) -> QPtr<QObject>[src]

Returns the expression's scope object, if provided, otherwise 0.

Calls C++ function: QObject* QQmlExpression::scopeObject() const.

C++ documentation:

Returns the expression's scope object, if provided, otherwise 0.

In addition to data provided by the expression's QQmlContext, the scope object's properties are also in scope during the expression's evaluation.

pub unsafe fn set_expression(&self, arg1: impl CastInto<Ref<QString>>)[src]

Set the expression to expression.

Calls C++ function: void QQmlExpression::setExpression(const QString& arg1).

C++ documentation:

Set the expression to expression.

See also expression().

pub unsafe fn set_notify_on_value_changed(&self, arg1: bool)[src]

Sets whether the valueChanged() signal is emitted when the expression's evaluated value changes.

Calls C++ function: void QQmlExpression::setNotifyOnValueChanged(bool arg1).

C++ documentation:

Sets whether the valueChanged() signal is emitted when the expression's evaluated value changes.

If notifyOnChange is true, the QQmlExpression will monitor properties involved in the expression's evaluation, and emit QQmlExpression::valueChanged() if they have changed. This allows an application to ensure that any value associated with the result of the expression remains up to date.

If notifyOnChange is false (default), the QQmlExpression will not montitor properties involved in the expression's evaluation, and QQmlExpression::valueChanged() will never be emitted. This is more efficient if an application wants a "one off" evaluation of the expression.

See also notifyOnValueChanged().

pub unsafe fn set_source_location_3a(
    &self,
    file_name: impl CastInto<Ref<QString>>,
    line: c_int,
    column: c_int
)
[src]

Set the location of this expression to line and column of url. This information is used by the script engine.

Calls C++ function: void QQmlExpression::setSourceLocation(const QString& fileName, int line, int column = …).

C++ documentation:

Set the location of this expression to line and column of url. This information is used by the script engine.

pub unsafe fn set_source_location_2a(
    &self,
    file_name: impl CastInto<Ref<QString>>,
    line: c_int
)
[src]

Set the location of this expression to line and column of url. This information is used by the script engine.

Calls C++ function: void QQmlExpression::setSourceLocation(const QString& fileName, int line).

C++ documentation:

Set the location of this expression to line and column of url. This information is used by the script engine.

pub unsafe fn source_file(&self) -> CppBox<QString>[src]

Returns the source file URL for this expression. The source location must have been previously set by calling setSourceLocation().

Calls C++ function: QString QQmlExpression::sourceFile() const.

C++ documentation:

Returns the source file URL for this expression. The source location must have been previously set by calling setSourceLocation().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QQmlExpression::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QQmlExpression::trUtf8(const char* s, const char* c, int n).

Trait Implementations

impl CppDeletable for QQmlExpression[src]

unsafe fn delete(&self)[src]

Destroy the QQmlExpression instance.

Calls C++ function: virtual [destructor] void QQmlExpression::~QQmlExpression().

C++ documentation:

Destroy the QQmlExpression instance.

impl Deref for QQmlExpression[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QQmlExpression* ptr).

impl DynamicCast<QQmlExpression> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QQmlExpression>[src]

Calls C++ function: QQmlExpression* dynamic_cast<QQmlExpression*>(QObject* ptr).

impl StaticDowncast<QQmlExpression> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QQmlExpression>[src]

Calls C++ function: QQmlExpression* static_cast<QQmlExpression*>(QObject* ptr).

impl StaticUpcast<QObject> for QQmlExpression[src]

unsafe fn static_upcast(ptr: Ptr<QQmlExpression>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QQmlExpression* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.