Expression QML Type

(BETA) Evaluates JavaScript expressions. More...

Import Statement: import ArcGIS.AppFramework.Scripting 1.0

Properties

Signals

Methods

Detailed Description

The Expression component evaluates JavaScript expressions within a QML context.

The following code snippet evaluates the expression "a * b", where 'a' is counting up from 1 and 'b' is set to 1000. The code uses the PropertySet component to define the QML context where 'a' and 'b' are taken from, and you will get notifications of the expression changing because of either 'a' or 'b'.

Item {
    Label {
        id: results
    }

    Expression {
        id: expression
        onValueChanged: results.text = expression.evaluate();
    }

    PropertySet {
        id: propertySet
    }

    Timer {
        id: timer
        repeat: true
        interval: 1000
        onTriggered: propertySet.a++;
    }

    Component.onCompleted: {
        propertySet.a = 1;
        propertySet.b = 1000;
        expression.scope = propertySet;
        expression.text = "a * b";
        results.text = expression.evaluate();
        expression.notifyOnValueChange = true;
        timer.start();
    }
}

Property Documentation

[read-only] errorString : string

Contains the error string reflecting any problems encountered in evaluating the expression.


[read-only] expressionString : string

A JavaScript expression returned as a string.


[read-only] isLiteralValue : bool

Returns true if the script supplied to the component contains an undefined, null, boolean, string, or number value. Otherwise, returns false.


[read-only] literalValue : var

Returns the script expressed as an undefined, null, boolean, number, or string value.


notifyOnValueChange : bool

Indicates whether the app will provide notifications of the expression value changing due to one of its dependent values changing.


scope : object

A QML context for accessing local variables.


script : QQmlScriptString

A JavaScript expression, provided as a script.


text : string

A JavaScript expression, provided as a string.


Signal Documentation

valueChanged()

Signal emitted when the resulting value of the JavaScript expression has changed.

Note: The corresponding handler is onValueChanged.


Method Documentation

clear()

Resets the component, allowing it to be ready to process a new expression.


object evaluate()

Returns the Javascript expression as a value.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.