PropertySet QML Type

Set key-value pairs that can be used in QML bindings. More...

Import Statement: import ArcGIS.AppFramework 1.0
Inherited By:

NetworkRequestHeaders

Properties

Methods

Detailed Description

The PropertySet component provides a convenient way to expose domain data to the UI layer, containing tools to assign set key-value pairs. This binding is dynamic; whenever a key's value is updated, anything bound to that key will also be updated.

This code sample uses PropertySet to allow the user to enter values for two properties, propWidth and propLength, and showing the resulting area using property binding. It also demonstrates how you use replaceVariables to generate formatted text.

Column {
    TextField {
        id: widthTextField
        placeholderText: qsTr("Property Width")
        onTextChanged: propertySet.propWidth = parseFloat(text)
        Component.onCompleted: text = "21"
    }

    TextField {
        id: lengthTextField
        placeholderText: qsTr("Property Length")
        onTextChanged: propertySet.propLength = parseFloat(text)
        Component.onCompleted: text = "35"
    }

    TextField {
        id: areaTextField
        text: propertySet.propWidth * propertySet.propLength // 735
    }

    Label {
        id: summaryText
        text: getSummaryText(propertySet.propWidth, propertySet.propLength)
        function getSummaryText(__width, __length) {
            return propertySet.replaceVariables("width: @propWidth@ length: @propLength@", false, "@key@") // width: 21 length: 35
        }
    }

    PropertySet {
        id: propertySet
    }
}

Property Documentation

json : object

Populates the PropertySet object from a JSON string.

samplePropertySet.json = {"a":"A1","b":"A2", "c":"A2"}

Method Documentation

clear()

Clears all associated key values.

samplePropertySet.clear()

bool containsKey(string key)

Returns true if the set contains the given key. Otherwise, returns false.

if(samplePropertySet.containsKey("a"))
console.log(samplePropertySet["a"]) // returns A1

The key parameter

The key to search for.


QStringList containsValue(object value)

Returns the list of all the keys which matches the given value in the property set.

console.log(samplePropertySet.containsValue("A2")) // returns b,c

The value parameter

The value to search for.


string replaceVariables(string text)

Overwrites a pre-existing value with the given text. If a case sensitivity is not defined, it will default to false. The function will then return the value that was replaced.

The text parameter

The text string being used as the new variable.


string replaceVariables(string text, bool caseSensitive)

Overwrites a pre-existing value with the given text, that respects the defined case sensitivity. The function will then return the value that was replaced.

The text parameter

The text string being used as the new variable.

The caseSensitive parameter

True if the value is to be case sensitive. Otherwise, false.


string replaceVariables(string text, bool caseSensitive, string variableFormat)

Overwrites a pre-existing value with the given text, in the defined case sensitivity and variable format. The function will then return the value that was replaced.

The text parameter

The text string being used as the new variable.

The caseSensitive parameter

True if the value is to be case sensitive. Otherwise, false.

The variableFormat parameter

The format the value will be entered in.


object value(string key, object defaultValue)

Returns the associated key value. If the key is not contained in the set, or the value is in some way invalid, returns the DefaultValue string.

var val = samplePropertySet.value("a",""); // returns A1

The key parameter

The key value returned.

The defaultValue parameter

This string is returned if the function is unable to return the requested key value.


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