C

string QML Basic Type

a free form text string. More...

The string type refers to a free form text string in quotes, e.g. "Hello world!".

Example:

Text { text: "Hello world!" }

Strings have a length attribute that holds the number of characters in the string.

The Qt Quick Ultralite string object extends the Javascript String object with the arg() function.

Example:

Text {
    property string message: "There are %1 items"
    property int count: 20

    text: message.arg(count)
}

Note: The following usages of arg() function are not supported in Qt Quick Ultralite:

  • Nested arg calls
    Text {
        text: "%1".arg("%1".arg("Hello")) // "Hello"
    }
  • Dynamically replacing numbered place marker
    Text {
        text: "%0 %1".arg("%1").arg("Hello") // "Hello Hello"
    }

    Note: You can achieve the above with an alternative qml syntax.

    Example:

    Text {
        property string nested: "%1".arg("Hello")
    
        text: "%1".arg(nested) // "Hello"
    }
    Text {
        property string replaced: "%0 %1".arg("%1")
    
        text: replaced.arg("Hello") // "Hello Hello"
    }

This basic type is provided by the QML language.

See also string and JavaScript environment for Qt Quick Ultralite applications.

Available under certain Qt licenses.
Find out more.