aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/src/appdevguide/usecases/text.qdoc
blob: 2507df7c3585851061e08c0c079cf559daa8c5db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page qtquick-usecase-text.html
\title Use Case - Displaying Text In QML
\brief Example of how to display text in QML
To display text the Text type is provided by the QtQuick module. For related uses, the \l{TextInput} and
\l{TextEdit} types provide editable text controls. For full HTML markup, see the \c{QtWebkit} module.

\section1 Displaying and Formatting Text

To display text in QML, create a Text item and set the text property to the text you wish to display. The Text item
will now display that text.

Several properties can be set on the Text item to style the entire block of text. These include color, font family,
font size, bold and italic. For a full list of properties, consult the \l{Text} type documentation.

Rich text like markup can be used to selectively style specific sections of text with a Text item. Set \l
Text::textFormat to Text.StyledText to use this functionality. More details are available in the documentation of the
\l{Text} type.

\section1 Laying out Text

By default, Text will display the text as a single line unless it contains embedded newlines. To wrap the line, set the
wrapMode property and give the text an explicit width for it to wrap to. If the width or height is not explicitly set,
reading these properties will return the parameters of the bounding rect of the text (if you have explicitly set width
or height, you can still use paintedWidth and paintedHeight). With these parameters in mind, the Text can be positioned
like any other Item.

\section1 Example Code
\snippet qml/usecases/text.qml 0
\image qml-uses-text.png

*/