![]() |
Home · All Classes · All Functions · Overviews |
[Inherits Item]
The Text item allows you to add formatted text to a scene. More...
|
|
It can display both plain and rich text. For example:
Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" } Text { text: "<b>Hello</b> <i>World!</i>" }
If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless wrap is set, it will always prefer width to height (all text will be placed on a single line).
The elide property can alternatively be used to fit a single line of plain text to a set width.
Text provides read-only text. For editable text, see TextEdit.
color : color |
The text color.
//green text using hexadecimal notation
Text { color: "#00FF00"; ... }
//steelblue text using SVG color name
Text { color: "steelblue"; ... }
Set this property to elide parts of the text fit to the Text item's width. The text will only elide if an explicit width has been set.
This property cannot be used with wrap enabled or with rich text.
Eliding can be ElideNone (the default), ElideLeft, ElideMiddle, or ElideRight.
If the text is a multi-length string, and the mode is not ElideNone, the first string that fits will be used, otherwise the last will be elided.
Multi-length strings are ordered from longest to shortest, separated by the Unicode "String Terminator" character U009C (write this in QML with "\u009C" or "\x9C").
font.family : string |
font.bold : bool |
font.italic : bool |
font.underline : bool |
font.pointSize : real |
font.pixelSize : int |
Set the Text's font attributes.
Sets the horizontal and vertical alignment of the text within the Text items width and height. By default, the text is top-left aligned.
The valid values for horizontalAlignment are AlignLeft, AlignRight and AlignHCenter. The valid values for verticalAlignment are AlignTop, AlignBottom and AlignVCenter.
smooth : bool |
Set this property if you want the text to be smoothly scaled or transformed. Smooth filtering gives better visual quality, but is slower. If the item is displayed at its natural size, this property has no visual or performance effect.
Note: Generally scaling artifacts are only visible if the item is stationary on the screen. A common pattern when animating an item is to disable smooth filtering at the beginning of the animation and reenable it at the conclusion.
Set an additional text style.
Supported text styles are Normal, Outline, Raised and Sunken.
Row { Text { font.pointSize: 24; text: "Normal" } Text { font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" } Text { font.pointSize: 24; text: "Outline"; style: Text.Outline; styleColor: "red" } Text { font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" } }
styleColor : color |
Defines the secondary color used by text styles.
styleColor is used as the outline color for outlined text, and as the shadow color for raised or sunken text. If no style has been set, it is not used at all.
text : string |
The text to display. Text supports both plain and rich text strings.
The item will try to automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText().
The way the text property should be displayed.
Supported text formats are AutoText, PlainText, RichText and StyledText
The default is AutoText. If the text format is AutoText the text element will automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText().
StyledText is an optimized format supporting some basic text styling markup, in the style of html 3.2:
<font size="4" color="#ff0000">font size and color</font> <b>bold</b> <i>italic</i> <br> > < &
StyledText parser is strict, requiring tags to be correctly nested.
Column { TextEdit { font.pointSize: 24 text: "<b>Hello</b> <i>World!</i>" } TextEdit { font.pointSize: 24 textFormat: "RichText" text: "<b>Hello</b> <i>World!</i>" } TextEdit { font.pointSize: 24 textFormat: "PlainText" text: "<b>Hello</b> <i>World!</i>" } } |
wrap : bool |
Set this property to wrap the text to the Text item's width. The text will only wrap if an explicit width has been set.
Wrapping is done on word boundaries (i.e. it is a "word-wrap"). If the text cannot be word-wrapped to the specified width it will be partially drawn outside of the item's bounds. If this is undesirable then enable clipping on the item (Item::clip).
Wrapping is off by default.
This handler is called when the user clicks on a link embedded in the text.
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.7.0 |