SafeText QML Type

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

Import Statement: import QtSafeRenderer 1.0


Detailed Description

The SafeText object is generated build for SafeRenderer. For that reason the text cannot be changed on runtime. 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 how to use the SafeText type:

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

Property Documentation

color : color

The text color.

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.hintingPreference : enumeration

Sets the preferred hinting on the text. This is a hint to the underlying text rendering system to use a certain level of hinting, and has varying support across platforms. See the table in the documentation for QFont::HintingPreference for more details.

Font.PreferDefaultHinting - Use the default hinting level for the target platform.

Font.PreferNoHinting - If possible, render text without hinting the outlines of the glyphs. The text layout will be typographically accurate, using the same metrics as are used e.g. when printing.

Font.PreferVerticalHinting - If possible, render text with no horizontal hinting, but align glyphs to the pixel grid in the vertical direction. The text will appear crisper on displays where the density is too low to give an accurate rendering of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's layout will be scalable to higher density devices (such as printers) without impacting details such as line breaks.

Font.PreferFullHinting - If possible, render text with hinting in both horizontal and vertical directions. The text will be altered to optimize legibility on the target device, but since the metrics will depend on the target size of the text, the positions of glyphs, line breaks, and other typographical detail will not scale, meaning that a text layout may look different on devices with different pixel densities.

SafeText { text: "Hello"; font.hintingPreference: Font.PreferVerticalHinting }

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. Use pointSize to set the size of the font in a device independent manner.

font.pointSize : real

Sets the font size in points. The point size must be greater than zero.

horizontalAlignment : enumeration

Sets the horizontal and alignment of the text within the SafeText items width and height. 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 Text.AlignLeft, Text.AlignRight, Text.AlignHCenter and Text.AlignJustify.

text : string

The text to display.

wrapMode : enumeration

Set this property to wrap the text to the SafeText item's width. The text will only wrap if an explicit width has been set. wrapMode can be one of:

  • Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then contentWidth will exceed a set width.
  • Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, contentWidth will exceed a set width.
  • Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
  • Text.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.