This file is indexed.

/usr/share/qt5/doc/qtquickcontrols/styling-circulargauge.html is in qtquickcontrols5-doc-html 5.5.1-1ubuntu1.

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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- styling-circulargauge.qdoc -->
  <title>Styling CircularGauge | Qt Quick Controls 5.5</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>Qt 5.5</li>
<li><a href="qtquickcontrols-index.html">Qt Quick Controls</a></li>
<li>Styling CircularGauge</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
    </ul>
    </div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level2"><a href="#the-needle-component">The Needle Component</a></li>
<li class="level2"><a href="#the-foreground-component">The Foreground Component</a></li>
<li class="level2"><a href="#the-tickmark-label-component">The Tickmark Label Component</a></li>
<li class="level2"><a href="#the-tickmark-component">The Tickmark Component</a></li>
<li class="level2"><a href="#the-minor-tickmark-component">The Minor Tickmark Component</a></li>
<li class="level2"><a href="#the-background-component">The Background Component</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Styling CircularGauge</h1>
<span class="subtitle"></span>
<!-- $$$styling-circulargauge.html-description -->
<div class="descr"> <a name="details"></a>
<a name="styling-circulargauge-needle"></a><a name="the-needle-component"></a>
<h3 >The Needle Component</h3>
<p>The <a href="qml-qtquick-controls-styles-circulargaugestyle.html#needle-prop">needle</a> component is rotated around the gauge to represent the current value.</p>
<p>Starting from the default style, we'll add a very basic white needle:</p>
<pre class="qml"><span class="name">needle</span>: <span class="name">Rectangle</span> {
    <span class="name">y</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.15</span>
    <span class="name">implicitWidth</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.03</span>
    <span class="name">implicitHeight</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.9</span>
    <span class="name">antialiasing</span>: <span class="number">true</span>
    <span class="name">color</span>: <span class="string">&quot;#e5e5e5&quot;</span>
}</pre>
<p class="centerAlign"><img src="images/styling-circulargauge-needle-example.png" alt="" /></p><p>As mentioned in the documentation for <a href="qml-qtquick-controls-styles-circulargaugestyle.html">CircularGaugeStyle</a>, <code>implicitWidth</code> and <code>implicitHeight</code> properties need to be set. This is so that the needle can be positioned properly. We always scale items by the <a href="qml-qtquick-controls-styles-circulargaugestyle.html#outerRadius-prop">outerRadius</a> property of the style, ensuring the control resizes gracefully.</p>
<p>We offset the needle vertically so that its back sits beyond the knob.</p>
<a name="styling-circulargauge-foreground"></a><a name="the-foreground-component"></a>
<h3 >The Foreground Component</h3>
<p>We've now changed the needle, but the default knob is still there; let's replace it. The <a href="qml-qtquick-controls-styles-circulargaugestyle.html#foreground-prop">foreground</a> component defines the default knob, so we can specify our own by overriding it (note that we could also set it to <code>null</code> if we didn't want a foreground):</p>
<pre class="qml"><span class="name">foreground</span>: <span class="name">Item</span> {
    <span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
        <span class="name">width</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.2</span>
        <span class="name">height</span>: <span class="name">width</span>
        <span class="name">radius</span>: <span class="name">width</span> <span class="operator">/</span> <span class="number">2</span>
        <span class="name">color</span>: <span class="string">&quot;#e5e5e5&quot;</span>
        <span class="name">anchors</span>.centerIn: <span class="name">parent</span>
    }
}</pre>
<p class="centerAlign"><img src="images/styling-circulargauge-knob-example.png" alt="" /></p><p>Firstly, we create a circle from the Rectangle item by setting the radius to be half the width (either width or height will work here; they are always equal in this case). We make it a child of the Item, because the foreground fills the gauge. We then center it within the Item.</p>
<p>We set the color of the knob to the same white that we used before.</p>
<a name="styling-circulargauge-tickmarklabel"></a><a name="the-tickmark-label-component"></a>
<h3 >The Tickmark Label Component</h3>
<p>Suppose we want to caution the user if the value displayed by the gauge goes above or below a certain range. We could present this range to the user in several ways:</p>
<ol class="A">
<li>Change the color of the tickmarks depending on <code>styleData.value</code></li>
<li>Add an image to the background</li>
<li>Draw it with <a href="../qtquick/qml-qtquick-canvas.html">Canvas</a></li>
</ol>
<p>We'll choose options 1 and 3, as they are more flexible than using an image.</p>
<p>Firstly, let's change the color of the three highest tickmark labels:</p>
<pre class="qml"><span class="name">tickmarkLabel</span>:  <span class="name">Text</span> {
    <span class="name">font</span>.pixelSize: <span class="name">Math</span>.<span class="name">max</span>(<span class="number">6</span>, <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.1</span>)
    <span class="name">text</span>: <span class="name">styleData</span>.<span class="name">value</span>
    <span class="name">color</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&gt;=</span> <span class="number">80</span> ? <span class="string">&quot;#e34c22&quot;</span> : <span class="string">&quot;#e5e5e5&quot;</span>
    <span class="name">antialiasing</span>: <span class="number">true</span>
}</pre>
<p class="centerAlign"><img src="images/styling-circulargauge-tickmarkLabel-example.png" alt="tickmarkLabel" /></p><p>We also change the color of the rest of the labels to the same white that we used for the needle and knob.</p>
<a name="styling-circulargauge-tickmark"></a><a name="the-tickmark-component"></a>
<h3 >The Tickmark Component</h3>
<p>Now let's do the same for the three highest tickmarks:</p>
<pre class="qml"><span class="name">tickmark</span>: <span class="name">Rectangle</span> {
    <span class="name">visible</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&lt;</span> <span class="number">80</span> <span class="operator">||</span> <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">%</span> <span class="number">10</span> <span class="operator">==</span> <span class="number">0</span>
    <span class="name">implicitWidth</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.02</span>
    <span class="name">antialiasing</span>: <span class="number">true</span>
    <span class="name">implicitHeight</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.06</span>
    <span class="name">color</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&gt;=</span> <span class="number">80</span> ? <span class="string">&quot;#e34c22&quot;</span> : <span class="string">&quot;#e5e5e5&quot;</span>
}</pre>
<p class="centerAlign"><img src="images/styling-circulargauge-tickmark-example.png" alt="tickmark" /></p><a name="styling-circulargauge-minortickmark"></a><a name="the-minor-tickmark-component"></a>
<h3 >The Minor Tickmark Component</h3>
<p>For the minor tickmarks, we'll only show those which are not higher than <code>80</code>:</p>
<pre class="qml"><span class="name">minorTickmark</span>: <span class="name">Rectangle</span> {
    <span class="name">visible</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&lt;</span> <span class="number">80</span>
    <span class="name">implicitWidth</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.01</span>
    <span class="name">antialiasing</span>: <span class="number">true</span>
    <span class="name">implicitHeight</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.03</span>
    <span class="name">color</span>: <span class="string">&quot;#e5e5e5&quot;</span>
}</pre>
<p class="centerAlign"><img src="images/styling-circulargauge-minorTickmark-example.png" alt="minorTickmark" /></p><p>This is because we'll draw something between that range in the next section.</p>
<a name="styling-circulargauge-background"></a><a name="the-background-component"></a>
<h3 >The Background Component</h3>
<p>We'll display the range that indicates caution with an orange arc:</p>
<pre class="qml"><span class="keyword">function</span> <span class="name">degreesToRadians</span>(<span class="name">degrees</span>) {
    <span class="keyword">return</span> <span class="name">degrees</span> <span class="operator">*</span> (<span class="name">Math</span>.<span class="name">PI</span> <span class="operator">/</span> <span class="number">180</span>);
}

<span class="name">background</span>: <span class="name">Canvas</span> {
    <span class="name">onPaint</span>: {
        var <span class="name">ctx</span> = <span class="name">getContext</span>(<span class="string">&quot;2d&quot;</span>);
        <span class="name">ctx</span>.<span class="name">reset</span>();

        <span class="name">ctx</span>.<span class="name">beginPath</span>();
        <span class="name">ctx</span>.<span class="name">strokeStyle</span> <span class="operator">=</span> <span class="string">&quot;#e34c22&quot;</span>;
        <span class="name">ctx</span>.<span class="name">lineWidth</span> <span class="operator">=</span> <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.02</span>;

        <span class="name">ctx</span>.<span class="name">arc</span>(<span class="name">outerRadius</span>, <span class="name">outerRadius</span>, <span class="name">outerRadius</span> <span class="operator">-</span> <span class="name">ctx</span>.<span class="name">lineWidth</span> <span class="operator">/</span> <span class="number">2</span>,
            <span class="name">degreesToRadians</span>(<span class="name">valueToAngle</span>(<span class="number">80</span>) <span class="operator">-</span> <span class="number">90</span>), <span class="name">degreesToRadians</span>(<span class="name">valueToAngle</span>(<span class="number">100</span>) <span class="operator">-</span> <span class="number">90</span>));
        <span class="name">ctx</span>.<span class="name">stroke</span>();
    }
}</pre>
<p>We define a function to convert degrees to radians, which are the units used by <a href="../qtquick/qml-qtquick-canvas.html">Canvas</a>.</p>
<p>Next, we do the drawing of the range using Canvas. We draw an arc between <code>80</code> and <code>100</code>, using the <a href="qml-qtquick-controls-styles-circulargaugestyle.html#valueToAngle-method">valueToAngle()</a> function provided by <a href="qml-qtquick-controls-styles-circulargaugestyle.html">CircularGaugeStyle</a>. Note that we subtract <code>90</code> degrees before converting to radians, as our origin is north and Canvas' is east.</p>
<p>The finished product:</p>
<p class="centerAlign"><img src="images/styling-circulargauge-background-example.png" alt="background" /></p><p>The complete code for this example is as follows:</p>
<pre class="qml">import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Extras 1.4
import QtQuick.Extras.Private 1.0

<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">width</span>: <span class="number">300</span>
    <span class="name">height</span>: <span class="number">300</span>
    <span class="name">color</span>: <span class="string">&quot;#494d53&quot;</span>

    <span class="type">CircularGauge</span> {
        <span class="name">id</span>: <span class="name">gauge</span>
        <span class="name">anchors</span>.centerIn: <span class="name">parent</span>
        <span class="name">style</span>: <span class="name">CircularGaugeStyle</span> {
            <span class="name">id</span>: <span class="name">style</span>

            <span class="keyword">function</span> <span class="name">degreesToRadians</span>(<span class="name">degrees</span>) {
                <span class="keyword">return</span> <span class="name">degrees</span> <span class="operator">*</span> (<span class="name">Math</span>.<span class="name">PI</span> <span class="operator">/</span> <span class="number">180</span>);
            }

            <span class="name">background</span>: <span class="name">Canvas</span> {
                <span class="name">onPaint</span>: {
                    var <span class="name">ctx</span> = <span class="name">getContext</span>(<span class="string">&quot;2d&quot;</span>);
                    <span class="name">ctx</span>.<span class="name">reset</span>();

                    <span class="name">ctx</span>.<span class="name">beginPath</span>();
                    <span class="name">ctx</span>.<span class="name">strokeStyle</span> <span class="operator">=</span> <span class="string">&quot;#e34c22&quot;</span>;
                    <span class="name">ctx</span>.<span class="name">lineWidth</span> <span class="operator">=</span> <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.02</span>;

                    <span class="name">ctx</span>.<span class="name">arc</span>(<span class="name">outerRadius</span>, <span class="name">outerRadius</span>, <span class="name">outerRadius</span> <span class="operator">-</span> <span class="name">ctx</span>.<span class="name">lineWidth</span> <span class="operator">/</span> <span class="number">2</span>,
                        <span class="name">degreesToRadians</span>(<span class="name">valueToAngle</span>(<span class="number">80</span>) <span class="operator">-</span> <span class="number">90</span>), <span class="name">degreesToRadians</span>(<span class="name">valueToAngle</span>(<span class="number">100</span>) <span class="operator">-</span> <span class="number">90</span>));
                    <span class="name">ctx</span>.<span class="name">stroke</span>();
                }
            }

            <span class="name">tickmark</span>: <span class="name">Rectangle</span> {
                <span class="name">visible</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&lt;</span> <span class="number">80</span> <span class="operator">||</span> <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">%</span> <span class="number">10</span> <span class="operator">==</span> <span class="number">0</span>
                <span class="name">implicitWidth</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.02</span>
                <span class="name">antialiasing</span>: <span class="number">true</span>
                <span class="name">implicitHeight</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.06</span>
                <span class="name">color</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&gt;=</span> <span class="number">80</span> ? <span class="string">&quot;#e34c22&quot;</span> : <span class="string">&quot;#e5e5e5&quot;</span>
            }

            <span class="name">minorTickmark</span>: <span class="name">Rectangle</span> {
                <span class="name">visible</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&lt;</span> <span class="number">80</span>
                <span class="name">implicitWidth</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.01</span>
                <span class="name">antialiasing</span>: <span class="number">true</span>
                <span class="name">implicitHeight</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.03</span>
                <span class="name">color</span>: <span class="string">&quot;#e5e5e5&quot;</span>
            }

            <span class="name">tickmarkLabel</span>:  <span class="name">Text</span> {
                <span class="name">font</span>.pixelSize: <span class="name">Math</span>.<span class="name">max</span>(<span class="number">6</span>, <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.1</span>)
                <span class="name">text</span>: <span class="name">styleData</span>.<span class="name">value</span>
                <span class="name">color</span>: <span class="name">styleData</span>.<span class="name">value</span> <span class="operator">&gt;=</span> <span class="number">80</span> ? <span class="string">&quot;#e34c22&quot;</span> : <span class="string">&quot;#e5e5e5&quot;</span>
                <span class="name">antialiasing</span>: <span class="number">true</span>
            }

            <span class="name">needle</span>: <span class="name">Rectangle</span> {
                <span class="name">y</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.15</span>
                <span class="name">implicitWidth</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.03</span>
                <span class="name">implicitHeight</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.9</span>
                <span class="name">antialiasing</span>: <span class="number">true</span>
                <span class="name">color</span>: <span class="string">&quot;#e5e5e5&quot;</span>
            }

            <span class="name">foreground</span>: <span class="name">Item</span> {
                <span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
                    <span class="name">width</span>: <span class="name">outerRadius</span> <span class="operator">*</span> <span class="number">0.2</span>
                    <span class="name">height</span>: <span class="name">width</span>
                    <span class="name">radius</span>: <span class="name">width</span> <span class="operator">/</span> <span class="number">2</span>
                    <span class="name">color</span>: <span class="string">&quot;#e5e5e5&quot;</span>
                    <span class="name">anchors</span>.centerIn: <span class="name">parent</span>
                }
            }
        }
    }
}</pre>
</div>
<!-- @@@styling-circulargauge.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
   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>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>