/usr/share/qt5/doc/qtdoc/qtquick-usecase-text.html is in qt5-doc-html 5.3.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- text.qdoc -->
<title>Use Case - Displaying Text In QML | QtDoc 5.3</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li><a href="index.html">Qt 5.3</a></li>
<li>Use Case - Displaying Text In QML</li>
<li id="buildversion">
Qt 5.3.2 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#displaying-and-formatting-text">Displaying and Formatting Text</a></li>
<li class="level1"><a href="#laying-out-text">Laying out Text</a></li>
<li class="level1"><a href="#example-code">Example Code</a></li>
</ul>
</div>
<h1 class="title">Use Case - Displaying Text In QML</h1>
<span class="subtitle"></span>
<!-- $$$qtquick-usecase-text.html-description -->
<div class="descr"> <a name="details"></a>
<a name="displaying-and-formatting-text"></a>
<h2>Displaying and Formatting Text</h2>
<p>To display text in QML, create a Text item and set the text property to the text you wish to display. The Text item will now display that text.</p>
<p>Several properties can be set on the Text item to style the entire block of text. These include color, font family, font size, bold and italic. For a full list of properties, consult the <a href="../qtquick/qml-qtquick-text.html">Text</a> type documentation.</p>
<p>Rich text like markup can be used to selectively style specific sections of text with a Text item. Set <a href="../qtquick/qml-qtquick-text.html#textFormat-prop">Text::textFormat</a> to Text.StyledText to use this functionality. More details are available in the documentation of the <a href="../qtquick/qml-qtquick-text.html">Text</a> type.</p>
<a name="laying-out-text"></a>
<h2>Laying out Text</h2>
<p>By default, Text will display the text as a single line unless it contains embedded newlines. To wrap the line, set the wrapMode property and give the text an explicit width for it to wrap to. If the width or height is not explicitly set, reading these properties will return the parameters of the bounding rect of the text (if you have explicitly set width or height, you can still use paintedWidth and paintedHeight). With these parameters in mind, the Text can be positioned like any other Item.</p>
<a name="example-code"></a>
<h2>Example Code</h2>
<pre class="qml">import QtQuick 2.3
<span class="type"><a href="../qtquick/qml-qtquick-item.html">Item</a></span> {
<span class="name">id</span>: <span class="name">root</span>
<span class="name">width</span>: <span class="number">480</span>
<span class="name">height</span>: <span class="number">320</span>
<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">color</span>: <span class="string">"#272822"</span>
<span class="name">width</span>: <span class="number">480</span>
<span class="name">height</span>: <span class="number">320</span>
}
<span class="type"><a href="../qtquick/qml-qtquick-column.html">Column</a></span> {
<span class="name">spacing</span>: <span class="number">20</span>
<span class="type"><a href="../qtquick/qml-qtquick-text.html">Text</a></span> {
<span class="name">text</span>: <span class="string">'I am the very model of a modern major general!'</span>
<span class="comment">// color can be set on the entire element with this property</span>
<span class="name">color</span>: <span class="string">"yellow"</span>
}
<span class="type"><a href="../qtquick/qml-qtquick-text.html">Text</a></span> {
<span class="comment">// For text to wrap, a width has to be explicitly provided</span>
<span class="name">width</span>: <span class="name">root</span>.<span class="name">width</span>
<span class="comment">// This setting makes the text wrap at word boundaries when it goes past the width of the Text object</span>
<span class="name">wrapMode</span>: <span class="name">Text</span>.<span class="name">WordWrap</span>
<span class="comment">// You can use \ to escape quotation marks, or to add new lines (\n). Use \\ to get a \ in the string</span>
<span class="name">text</span>: <span class="string">'I am the very model of a modern major general. I\'ve information vegetable, animal and mineral. I know the kings of england and I quote the fights historical; from Marathon to Waterloo in order categorical.'</span>
<span class="comment">// color can be set on the entire element with this property</span>
<span class="name">color</span>: <span class="string">"white"</span>
}
<span class="type"><a href="../qtquick/qml-qtquick-text.html">Text</a></span> {
<span class="name">text</span>: <span class="string">'I am the very model of a modern major general!'</span>
<span class="comment">// color can be set on the entire element with this property</span>
<span class="name">color</span>: <span class="string">"yellow"</span>
<span class="comment">// font properties can be set effciently on the whole string at once</span>
<span class="type">font</span> { <span class="name">family</span>: <span class="string">'Courier'</span>; <span class="name">pixelSize</span>: <span class="number">20</span>; <span class="name">italic</span>: <span class="number">true</span>; <span class="name">capitalization</span>: <span class="name">Font</span>.<span class="name">SmallCaps</span> }
}
<span class="type"><a href="../qtquick/qml-qtquick-text.html">Text</a></span> {
<span class="comment">// HTML like markup can also be used</span>
<span class="name">text</span>: <span class="string">'<font color="white">I am the <b>very</b> model of a modern <i>major general</i>!</font>'</span>
<span class="comment">// This could also be written font { pointSize: 14 }. Both syntaxes are valid.</span>
<span class="name">font</span>.pointSize: <span class="number">14</span>
<span class="comment">// StyledText format supports fewer tags, but is more efficient than RichText</span>
<span class="name">textFormat</span>: <span class="name">Text</span>.<span class="name">StyledText</span>
}
}
}</pre>
<p class="centerAlign"><img src="images/qml-uses-text.png" alt="" /></p></div>
<!-- @@@qtquick-usecase-text.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2014 Digia Plc and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|