C

SafeText QML Type

Provides a QML text type which can be rendered in the Qt Safe Renderer runtime. More...

Import Statement: import Qt.SafeRenderer 2.0

Properties

Detailed Description

The text can be changed on runtime if runtimeEditable is set to true. The SafeText object communicates the scene position changes to the Safe Renderer runtime. For that purpose, a unique objectName property must be set.

Note: SafeText is not rendered properly if the font size is longer than 175.

The following code provides an example of the SafeText type:

SafeText {
    id: safeText
    objectName: "safeText"
    x: 256
    y: 8
    text: "Safe text.."
    color: "black"
    fillColor: "white"  // optional, but recommended to use fillColor for controlled background color
    font.pixelSize: 12
}

Property Documentation

color : color

This property holds the text color. This can be changed on run-time if the runtimeEditable is set to true.

The following code provides an example of a green text defined using hexadecimal notation:

SafeText {
    color: "#00FF00"
    text: "green text"
}

The following code provides an example of a steel blue text defined using an SVG color name:

SafeText {
    color: "steelblue"
    text: "blue text"
}

fillColor : color

This property holds the background fill color for text. This can be changed at run-time if the runtimeEditable is set to true.

The following code provides an example of a blue text background defined using hexadecimal notation:

SafeText {
    fillColor: "#0000FF"
    text: "text on blue background fill color"
}

The following code provides an example of a steel blue text background defined using an SVG color name:

SafeText {
    fillColor: "steelblue"
    text: "text on steelblue background fill color"
}

font.bold : bool

This property holds whether the font weight is bold.


font.italic : bool

This property holds whether the font has an italic style.


font.pixelSize : int

This property holds the font size in pixels.

Using this property makes the font device dependent.


height : real

This property holds the text's height. The default value is 64.


horizontalAlignment : enumeration

This property holds the horizontal alignment of the text within the SafeText width. Horizontal alignment follows the natural alignment of the text. For example, the text that is read from left to right will be aligned to the left.

The valid values for horizontalAlignment are SafeText.AlignLeft, SafeText.AlignRight, SafeText.AlignHCenter, and SafeText.AlignJustify.


objectName : string

This property holds the QObject::objectName for this specific object instance.


opacity : real

This property holds the opacity of the item. Opacity is specified as a number between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 1.0. For more information, see Opacity Property.


runtimeEditable : bool

This property holds whether it is possible to change text and color on run-time. Text and color changing needs to be done via SafeRenderer::QSafeEventSetText and SafeRenderer::QSafeEventSetColor events.

When set to true and you build a Qt Quick project, a .qpf2 file is generated for each font type that you use in dynamic SafeText QML types in your project. By default, this is set to false and an .srb file is generated.

When set to true, text and color can be changed on the run-time.


text : string

This property holds a text to display. This can be changed on run-time if the runtimeEditable is set to true.


verticalAlignment : enumeration

This property holds the vertical alignment of the text within the SafeText height. Horizontal alignment follows the natural alignment of the text.

The valid values for verticalAlignment are SafeText.AlignTop, SafeText.AlignBottom, and SafeText.AlignVCenter.


width : real

This property holds the text's width. The default value is 128.


wrapMode : enumeration

This property holds how the text will be wrapped. The text will be wrapped only if an explicit width has been set.

  • SafeText.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then the following exception will be thrown:

    SafeRenderer::QSafeTextLayout::OutOfBounds.

  • SafeText.WordWrap - wrapping is done on word boundaries only. If a word is too long, then the following exception will be thrown:

    SafeRenderer::QSafeTextLayout::OutOfBounds.

    Note: Text.WordWrap is not supported in SafeText when runtimeEditable is set to true.

  • SafeText.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
  • SafeText.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.

x : real

This property holds the x-coordinate in the text's position.


y : real

This property holds the y-coordinate in the text's position.


Available under certain Qt licenses.
Find out more.