C

SafeText QML Type

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

Import Statement: import QtSafeRenderer 1.1

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.

The following code provides an example of the SafeText type:

SafeText {
    id: safeText
    objectName: "safeText"
    x: 256
    y: 8
    text: "Safe text.."
    font.pointSize: 12
}

Property Documentation

x : real

y : real

width : real

height : real

Defines the text's position and size. The default value is 0.


color : color

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

An example of green text defined using hexadecimal notation:

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

An example of steel blue text defined using an SVG color name:

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

font.bold : bool

Sets whether the font weight is bold.


font.italic : bool

Sets whether the font has an italic style.


font.pixelSize : int

Sets the font size in pixels.

Using this function makes the font device dependent.


horizontalAlignment : enumeration

Sets the horizontal alignment of the text within the SafeText width. Horizontal alignment follows the natural alignment of the text, for example 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.


runtimeEditable : bool

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

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


verticalAlignment : enumeration

Sets 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.


wrapMode : enumeration

The mode to use to wrap the text. The text will only wrap 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.

Available under certain Qt licenses.
Find out more.