1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the examples of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 ** the names of its contributors may be used to endorse or promote
22 ** products derived from this software without specific prior written
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
44 \title QML Examples - Text
46 \brief This is a collection of QML examples
47 \image qml-text-example.png
49 This is a collection of small QML examples relating to text. Each example is
50 a small QML file, usually containing or emphasizing a particular element or
51 feature. You can run and observe the behavior of each example.
53 'Hello' shows how to change and animate the letter spacing of a Text element.
54 It uses a sequential animation to first animate the font.letterSpacing property
55 from 0 to 50 over 3 seconds and then move the text to a random position on screen:
56 \snippet examples/quick/text/fonts/hello.qml letterspacing
58 'Fonts' shows different ways of using fonts with the Text element.
59 Simply by name, using the font.family property directly:
60 \snippet examples/quick/text/fonts/fonts.qml name
61 or using a FontLoader element:
62 \snippet examples/quick/text/fonts/fonts.qml fontloader
63 or using a FontLoader and specifying a local font file:
64 \snippet examples/quick/text/fonts/fonts.qml fontloaderlocal
65 or finally using a FontLoader and specifying a remote font file:
66 \snippet examples/quick/text/fonts/fonts.qml fontloaderremote
68 'Available Fonts' shows how to use the QML global Qt object and a list view
69 to display all the fonts available on the system.
70 The ListView element uses the list of fonts available as its model:
71 \snippet examples/quick/text/fonts/availableFonts.qml model
72 Inside the delegate, the font family is set with the modelData:
73 \snippet examples/quick/text/fonts/availableFonts.qml delegate
75 'Banner' is a simple example showing how to create a banner using a row of text
76 elements and a NumberAnimation.
78 'Img tag' shows different ways of displaying images in a text elements using
81 'Text Layout' shows how to create a more complex layout for a text element.
82 This example lays out the text in two columns using the onLineLaidOut handler
83 that allows you to position and resize each line:
84 \snippet examples/quick/text/styledtext-layout.qml layout
93 Component.onCompleted: {
94 addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml"));
95 addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml"));
96 addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml"));
97 addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml"));
98 addExample("Img tag", "Embedding images into text", Qt.resolvedUrl("imgtag/imgtag.qml"));
99 addExample("Text Layout", "Flowing text around items", Qt.resolvedUrl("styledtext-layout.qml"));