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
9
To display text the Text type is provided by the \l {Qt Quick} module. For
10
related uses, the \l{TextInput} and \l{TextEdit} types provide editable text
11
controls. For full HTML markup, see the
12
\l {qtwebengine-index.html}{Qt WebEngine} module.
13
14
\section1 Displaying and formatting text
15
16
To display text in QML, create a Text item and set the text property to the
17
text you wish to display. The Text item will now display that text.
18
19
Several properties can be set on the Text item to style the entire block of
20
text. These include color, font family, font size, bold and italic. For a full
21
list of properties, consult the \l{Text} type documentation.
22
23
Rich text like markup can be used to selectively style specific sections of
24
text with a Text item. Set \l Text::textFormat to Text.StyledText to use this
25
functionality. More details are available in the documentation of the \l{Text}
26
type.
27
28
\section1 Laying out text
29
30
By default, Text will display the text as a single line unless it contains
31
embedded newlines. To wrap the line, set the wrapMode property and give the
32
text an explicit width for it to wrap to. If the width or height is not
33
explicitly set, reading these properties will return the parameters of the
34
bounding rect of the text (if you have explicitly set width or height, you can
35
still use paintedWidth and paintedHeight). With these parameters in mind, the
36
Text 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
44
When dealing with texts, applications must take into account various topics
45
such as the device's orientation and the language settings.
46
47
The 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
*/
qtdeclarative
src
quick
doc
src
getting-started
text.qdoc
Generated on
for Qt by
1.14.0