aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/src/appdevguide/usecases/text.qdoc
blob: d0b8901170d747d0add924ad703061fd80a474e8 (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) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** 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.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $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

*/