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