Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
text.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3/*!
4\page qtquick-usecase-text.html
5\title Displaying text
6\keyword Use Case - Displaying Text In QML
7\brief Example of how to display text in QML
8
9To display text the Text type is provided by the \l {Qt Quick} module. For
10related uses, the \l{TextInput} and \l{TextEdit} types provide editable text
11controls. For full HTML markup, see the
12\l {qtwebengine-index.html}{Qt WebEngine} module.
13
14\section1 Displaying and formatting text
15
16To display text in QML, create a Text item and set the text property to the
17text you wish to display. The Text item will now display that text.
18
19Several properties can be set on the Text item to style the entire block of
20text. These include color, font family, font size, bold and italic. For a full
21list of properties, consult the \l{Text} type documentation.
22
23Rich text like markup can be used to selectively style specific sections of
24text with a Text item. Set \l Text::textFormat to Text.StyledText to use this
25functionality. More details are available in the documentation of the \l{Text}
26type.
27
28\section1 Laying out text
29
30By default, Text will display the text as a single line unless it contains
31embedded newlines. To wrap the line, set the wrapMode property and give the
32text an explicit width for it to wrap to. If the width or height is not
33explicitly set, reading these properties will return the parameters of the
34bounding rect of the text (if you have explicitly set width or height, you can
35still use paintedWidth and paintedHeight). With these parameters in mind, the
36Text can be positioned like any other Item.
37
38\section1 Example Code
39\snippet qmlapp/usecases/text.qml 0
40\image qmlapp/qml-uses-text.png
41
42\section1 Internationalization and scalability
43
44When dealing with texts, applications must take into account various topics
45such as the device's orientation and the language settings.
46
47The following pages go into detail about these various topics.
48
49\list
50\li \l{Right-to-left User Interfaces}
51\li \l{Internationalization with Qt}
52\li \l{Scalability}
53\endlist
54
55*/