/usr/share/qt5/doc/qtquickcontrols2/qml-qtquick-controls2-spinbox.html is in qtquickcontrols2-5-doc-html 5.7.1-1.
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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickspinbox.cpp -->
<title>SpinBox QML Type | Qt Quick Controls 2 5.7</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
window.onload = function(){document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");};
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.7</td><td ><a href="qtquickcontrols2-index.html">Qt Quick Controls 2</a></td><td ><a href="qtquick-controls2-qmlmodule.html">QML Types</a></td><td >SpinBox QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.7.1 Reference Documentation</td>
</tr></table>
</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="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#custom-values">Custom Values</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">SpinBox QML Type</h1>
<span class="subtitle"></span>
<!-- $$$SpinBox-brief -->
<p>A spinbox control that allows the user to select from a set of preset values. <a href="#details">More...</a></p>
<!-- @@@SpinBox -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick.Controls 2.0</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.7</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-controls2-control.html">Control</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-controls2-spinbox-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#down-prop">down</a></b></b><ul>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#down.pressed-prop">down.pressed</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#down.indicator-prop">down.indicator</a></b></b> : Item</li>
</ul>
</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#editable-prop">editable</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#from-prop">from</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#stepSize-prop">stepSize</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#textFromValue-prop">textFromValue</a></b></b> : function</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#to-prop">to</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#up-prop">up</a></b></b><ul>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#up.pressed-prop">up.pressed</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#up.indicator-prop">up.indicator</a></b></b> : Item</li>
</ul>
</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#validator-prop">validator</a></b></b> : Validator</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#value-prop">value</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-controls2-spinbox.html#valueFromText-prop">valueFromText</a></b></b> : function</li>
</ul>
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
<li class="fn">void <b><b><a href="qml-qtquick-controls2-spinbox.html#decrease-method">decrease</a></b></b>()</li>
<li class="fn">void <b><b><a href="qml-qtquick-controls2-spinbox.html#increase-method">increase</a></b></b>()</li>
</ul>
<!-- $$$SpinBox-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
</p>
<p class="centerAlign"><img src="images/qtquickcontrols2-spinbox.png" alt="" /></p><p><a href="qml-qtquick-controls2-spinbox.html">SpinBox</a> allows the user to choose an integer value by clicking the up or down indicator buttons, or by pressing up or down on the keyboard. Optionally, <a href="qml-qtquick-controls2-spinbox.html">SpinBox</a> can be also made <a href="qml-qtquick-controls2-spinbox.html#editable-prop">editable</a>, so the user can enter a text value in the input field.</p>
<p>By default, <a href="qml-qtquick-controls2-spinbox.html">SpinBox</a> provides discrete values in the range of <code>[0-99]</code> with a <a href="qml-qtquick-controls2-spinbox.html#stepSize-prop">stepSize</a> of <code>1</code>.</p>
<pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-spinbox.html">SpinBox</a></span> {
<span class="name">value</span>: <span class="number">50</span>
}
</pre>
<a name="custom-values"></a>
<h3 >Custom Values</h3>
<p class="centerAlign"><img src="images/qtquickcontrols2-spinbox-textual.png" alt="" /></p><p>Even though <a href="qml-qtquick-controls2-spinbox.html">SpinBox</a> works on integer values, it can be customized to accept arbitrary input values. The following snippet demonstrates how <a href="qml-qtquick-controls2-spinbox.html#validator-prop">validator</a>, <a href="qml-qtquick-controls2-spinbox.html#textFromValue-prop">textFromValue</a> and <a href="qml-qtquick-controls2-spinbox.html#valueFromText-prop">valueFromText</a> can be used to customize the default behavior.</p>
<pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-spinbox.html">SpinBox</a></span> {
<span class="name">from</span>: <span class="number">0</span>
<span class="name">to</span>: <span class="name">items</span>.<span class="name">length</span> <span class="operator">-</span> <span class="number">1</span>
<span class="name">value</span>: <span class="number">1</span> <span class="comment">// "Medium"</span>
property <span class="type"><a href="../qtqml/qml-var.html">var</a></span> <span class="name">items</span>: [<span class="string">"Small"</span>, <span class="string">"Medium"</span>, <span class="string">"Large"</span>]
<span class="name">validator</span>: <span class="name">RegExpValidator</span> {
<span class="name">regExp</span>: new <span class="name">RegExp</span>(<span class="string">"(Small|Medium|Large)"</span>, <span class="string">"i"</span>)
}
<span class="name">textFromValue</span>: <span class="keyword">function</span>(<span class="name">value</span>) {
<span class="keyword">return</span> <span class="name">items</span>[<span class="name">value</span>];
}
<span class="name">valueFromText</span>: <span class="keyword">function</span>(<span class="name">text</span>) {
<span class="keyword">for</span> (<span class="keyword">var</span> <span class="name">i</span> = <span class="number">0</span>; <span class="name">i</span> <span class="operator"><</span> <span class="name">items</span>.<span class="name">length</span>; ++<span class="name">i</span>) {
<span class="keyword">if</span> (<span class="name">items</span>[<span class="name">i</span>].<span class="name">toLowerCase</span>().<span class="name">indexOf</span>(<span class="name">text</span>.<span class="name">toLowerCase</span>()) <span class="operator">===</span> <span class="number">0</span>)
<span class="keyword">return</span> <span class="name">i</span>
}
<span class="keyword">return</span> <span class="name">sb</span>.<span class="name">value</span>
}
}
</pre>
<p>In the same manner, <a href="qml-qtquick-controls2-spinbox.html">SpinBox</a> can be customized to accept floating point numbers:</p>
<p class="centerAlign"><img src="images/qtquickcontrols2-spinbox-double.png" alt="" /></p><pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-spinbox.html">SpinBox</a></span> {
<span class="name">id</span>: <span class="name">spinbox</span>
<span class="name">from</span>: <span class="number">0</span>
<span class="name">value</span>: <span class="number">110</span>
<span class="name">to</span>: <span class="number">100</span> <span class="operator">*</span> <span class="number">100</span>
<span class="name">stepSize</span>: <span class="number">100</span>
<span class="name">anchors</span>.centerIn: <span class="name">parent</span>
property <span class="type">int</span> <span class="name">decimals</span>: <span class="number">2</span>
property <span class="type">real</span> <span class="name">realValue</span>: <span class="name">value</span> <span class="operator">/</span> <span class="number">100</span>
<span class="name">validator</span>: <span class="name">DoubleValidator</span> {
<span class="name">bottom</span>: <span class="name">Math</span>.<span class="name">min</span>(<span class="name">spinbox</span>.<span class="name">from</span>, <span class="name">spinbox</span>.<span class="name">to</span>)
<span class="name">top</span>: <span class="name">Math</span>.<span class="name">max</span>(<span class="name">spinbox</span>.<span class="name">from</span>, <span class="name">spinbox</span>.<span class="name">to</span>)
}
<span class="name">textFromValue</span>: <span class="keyword">function</span>(<span class="name">value</span>, locale) {
<span class="keyword">return</span> <span class="name">Number</span>(<span class="name">value</span> <span class="operator">/</span> <span class="number">100</span>).<span class="name">toLocaleString</span>(<span class="name">locale</span>, <span class="string">'f'</span>, <span class="name">spinbox</span>.<span class="name">decimals</span>)
}
<span class="name">valueFromText</span>: <span class="keyword">function</span>(<span class="name">text</span>, locale) {
<span class="keyword">return</span> <span class="name">Number</span>.<span class="name">fromLocaleString</span>(<span class="name">locale</span>, <span class="name">text</span>) <span class="operator">*</span> <span class="number">100</span>
}
}
</pre>
<p><b>See also </b><a href="qml-qtquick-controls2-tumbler.html">Tumbler</a> and <a href="qtquickcontrols2-customize.html#customizing-spinbox">Customizing SpinBox</a>.</p>
<!-- @@@SpinBox -->
<h2>Property Documentation</h2>
<!-- $$$down -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="even" id="down-prop"><th class="centerAlign"><p><a name="down-prop"></a><b>down group</b></p></th></tr><tr valign="top" class="odd" id="down.pressed-prop"><td class="tblQmlPropNode"><p><a name="down.pressed-prop"></a><span class="name">down.pressed</span> : <span class="type">bool</span></p></td></tr><tr valign="top" class="odd" id="down.indicator-prop"><td class="tblQmlPropNode"><p><a name="down.indicator-prop"></a><span class="name">down.indicator</span> : <span class="type"><a href="../qtquick/qml-qtquick-item.html">Item</a></span></p></td></tr></table></div></div><div class="qmldoc"><p>These properties hold the down indicator item and whether it is pressed.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#decrease-method">decrease()</a>.</p>
</div></div><!-- @@@down -->
<br/>
<!-- $$$editable -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="editable-prop">
<td class="tblQmlPropNode"><p>
<a name="editable-prop"></a><span class="name">editable</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds whether the spinbox is editable. The default value is <code>false</code>.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#validator-prop">validator</a>.</p>
</div></div><!-- @@@editable -->
<br/>
<!-- $$$from -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="from-prop">
<td class="tblQmlPropNode"><p>
<a name="from-prop"></a><span class="name">from</span> : <span class="type">int</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the starting value for the range. The default value is <code>0</code>.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#to-prop">to</a> and <a href="qml-qtquick-controls2-spinbox.html#value-prop">value</a>.</p>
</div></div><!-- @@@from -->
<br/>
<!-- $$$stepSize -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="stepSize-prop">
<td class="tblQmlPropNode"><p>
<a name="stepSize-prop"></a><span class="name">stepSize</span> : <span class="type">int</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the step size. The default value is <code>1</code>.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#increase-method">increase()</a> and <a href="qml-qtquick-controls2-spinbox.html#decrease-method">decrease()</a>.</p>
</div></div><!-- @@@stepSize -->
<br/>
<!-- $$$textFromValue -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="textFromValue-prop">
<td class="tblQmlPropNode"><p>
<a name="textFromValue-prop"></a><span class="name">textFromValue</span> : <span class="type">function</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds a callback function that is called whenever an integer value needs to be converted to display text.</p>
<p>The callback function signature is <code>string function(value, locale)</code>. The function can have one or two arguments, where the first argument is the value to be converted, and the optional second argument is the locale that should be used for the conversion, if applicable.</p>
<p>The default implementation does the conversion using <a href="../qtqml/qml-qtqml-locale.html">Number.toLocaleString()</a>:</p>
<pre class="cpp">
textFromValue: function(value<span class="operator">,</span> locale) { <span class="keyword">return</span> Number(value)<span class="operator">.</span>toLocaleString(locale<span class="operator">,</span> <span class="char">'f'</span><span class="operator">,</span> <span class="number">0</span>); }
</pre>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#valueFromText-prop">valueFromText</a>, <a href="qml-qtquick-controls2-spinbox.html#validator-prop">validator</a>, and <a href="qml-qtquick-controls2-control.html#locale-prop">locale</a>.</p>
</div></div><!-- @@@textFromValue -->
<br/>
<!-- $$$to -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="to-prop">
<td class="tblQmlPropNode"><p>
<a name="to-prop"></a><span class="name">to</span> : <span class="type">int</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the end value for the range. The default value is <code>99</code>.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#from-prop">from</a> and <a href="qml-qtquick-controls2-spinbox.html#value-prop">value</a>.</p>
</div></div><!-- @@@to -->
<br/>
<!-- $$$up -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="even" id="up-prop"><th class="centerAlign"><p><a name="up-prop"></a><b>up group</b></p></th></tr><tr valign="top" class="odd" id="up.pressed-prop"><td class="tblQmlPropNode"><p><a name="up.pressed-prop"></a><span class="name">up.pressed</span> : <span class="type">bool</span></p></td></tr><tr valign="top" class="odd" id="up.indicator-prop"><td class="tblQmlPropNode"><p><a name="up.indicator-prop"></a><span class="name">up.indicator</span> : <span class="type"><a href="../qtquick/qml-qtquick-item.html">Item</a></span></p></td></tr></table></div></div><div class="qmldoc"><p>These properties hold the up indicator item and whether it is pressed.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#increase-method">increase()</a>.</p>
</div></div><!-- @@@up -->
<br/>
<!-- $$$validator -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="validator-prop">
<td class="tblQmlPropNode"><p>
<a name="validator-prop"></a><span class="name">validator</span> : <span class="type">Validator</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the input text validator for editable spinboxes. By default, <a href="qml-qtquick-controls2-spinbox.html">SpinBox</a> uses <a href="../qtquick/qml-qtquick-intvalidator.html">IntValidator</a> to accept input of integer numbers.</p>
<pre class="qml">
<span class="name">validator</span>: <span class="name">IntValidator</span> {
<span class="name">locale</span>: <span class="name">control</span>.<span class="name">locale</span>.<span class="name">name</span>
<span class="name">bottom</span>: <span class="name">Math</span>.<span class="name">min</span>(<span class="name">control</span>.<span class="name">from</span>, <span class="name">control</span>.<span class="name">to</span>)
<span class="name">top</span>: <span class="name">Math</span>.<span class="name">max</span>(<span class="name">control</span>.<span class="name">from</span>, <span class="name">control</span>.<span class="name">to</span>)
}
</pre>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#editable-prop">editable</a>, <a href="qml-qtquick-controls2-spinbox.html#textFromValue-prop">textFromValue</a>, <a href="qml-qtquick-controls2-spinbox.html#valueFromText-prop">valueFromText</a>, and <a href="qml-qtquick-controls2-control.html#locale-prop">locale</a>.</p>
</div></div><!-- @@@validator -->
<br/>
<!-- $$$value -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="value-prop">
<td class="tblQmlPropNode"><p>
<a name="value-prop"></a><span class="name">value</span> : <span class="type">int</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the value in the range <code>from</code> - <code>to</code>. The default value is <code>0</code>.</p>
</div></div><!-- @@@value -->
<br/>
<!-- $$$valueFromText -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="valueFromText-prop">
<td class="tblQmlPropNode"><p>
<a name="valueFromText-prop"></a><span class="name">valueFromText</span> : <span class="type">function</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds a callback function that is called whenever input text needs to be converted to an integer value.</p>
<p>The callback function signature is <code>int function(text, locale)</code>. The function can have one or two arguments, where the first argument is the text to be converted, and the optional second argument is the locale that should be used for the conversion, if applicable.</p>
<p>The default implementation does the conversion using <a href="../qtqml/qml-qtqml-locale.html">Number.fromLocaleString()</a>:</p>
<pre class="cpp">
valueFromText: function(text<span class="operator">,</span> locale) { <span class="keyword">return</span> Number<span class="operator">.</span>fromLocaleString(locale<span class="operator">,</span> text); }
</pre>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#textFromValue-prop">textFromValue</a>, <a href="qml-qtquick-controls2-spinbox.html#validator-prop">validator</a>, and <a href="qml-qtquick-controls2-control.html#locale-prop">locale</a>.</p>
</div></div><!-- @@@valueFromText -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$decrease -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="decrease-method">
<td class="tblQmlFuncNode"><p>
<a name="decrease-method"></a><span class="type">void</span> <span class="name">decrease</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Decreases the value by <a href="qml-qtquick-controls2-spinbox.html#stepSize-prop">stepSize</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#stepSize-prop">stepSize</a>.</p>
</div></div><!-- @@@decrease -->
<br/>
<!-- $$$increase -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="increase-method">
<td class="tblQmlFuncNode"><p>
<a name="increase-method"></a><span class="type">void</span> <span class="name">increase</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Increases the value by <a href="qml-qtquick-controls2-spinbox.html#stepSize-prop">stepSize</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls2-spinbox.html#stepSize-prop">stepSize</a>.</p>
</div></div><!-- @@@increase -->
<br/>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2016 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>
|