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\meta {keywords} {qmltopic}
6\title Displaying text
7\keyword Use Case - Displaying Text In QML
8\brief Example of how to display text in QML
9
10To display text the Text type is provided by the \l {Qt Quick} module. For
11related uses, the \l{TextInput} and \l{TextEdit} types provide editable text
12controls. For full HTML markup, see the
13\l {Qt WebEngine} module.
14
15\section1 Displaying and formatting text
16
17To display text in QML, create a Text item and set the text property to the
18text you wish to display. The Text item will now display that text.
19
20Several properties can be set on the Text item to style the entire block of
21text. These include color, font family, font size, bold and italic. For a full
22list of properties, consult the \l{Text} type documentation.
23
24Rich text like markup can be used to selectively style specific sections of
25text with a Text item. Set \l Text::textFormat to Text.StyledText to use this
26functionality. More details are available in the documentation of the \l{Text}
27type.
28
29\section1 Laying out text
30
31By default, Text will display the text as a single line unless it contains
32embedded newlines. To wrap the line, set the wrapMode property and give the
33text an explicit width for it to wrap to. If the width or height is not
34explicitly set, reading these properties will return the parameters of the
35bounding rect of the text (if you have explicitly set width or height, you can
36still use paintedWidth and paintedHeight). With these parameters in mind, the
37Text can be positioned like any other Item.
38
39\section1 Example Code
40\snippet qmlapp/usecases/text.qml 0
41\image qmlapp/qml-uses-text.png
42
43\section1 Internationalization and scalability
44
45When dealing with texts, applications must take into account various topics
46such as the device's orientation and the language settings.
47
48The following pages go into detail about these various topics.
49
50\list
51\li \l{Right-to-left User Interfaces}
52\li \l{Internationalization with Qt}
53\li \l{Scalability}
54\endlist
55
56*/