Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 399

qtdeclarative5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- basictypes.qdoc -->
  <title>QML Basic Types | Qt QML 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtqml-index.html">Qt QML</a></td><td >QML Basic Types</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.6 Reference Documentation</a></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="#supported-basic-types">Supported Basic Types</a></li>
<li class="level2"><a href="#basic-types-provided-by-the-qml-language">Basic Types Provided By The QML Language</a></li>
<li class="level2"><a href="#basic-types-provided-by-qml-modules">Basic Types Provided By QML Modules</a></li>
<li class="level1"><a href="#property-change-behavior-for-basic-types">Property Change Behavior for Basic Types</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QML Basic Types</h1>
<span class="subtitle"></span>
<!-- $$$qtqml-typesystem-basictypes.html-description -->
<div class="descr"> <a name="details"></a>
<p>QML supports a number of basic types.</p>
<p>A <i>basic type</i> is one that refers to a simple value, such as an <code>int</code> or a <code>string</code>. This contrasts with a <a href="qtqml-typesystem-topic.html#qml-object-types">QML Object Types</a>, which refers to an object with properties, signals, methods and so on. Unlike an object type, a basic type cannot be used to declare QML objects: it is not possible, for example, to declare an <code>int{}</code> object or a <code>size{}</code> object.</p>
<p>Basic types can be used to refer to:</p>
<ul>
<li>A single value (e.g&#x2e; <a href="qml-int.html">int</a> refers to a single number, <a href="qml-var.html">var</a> can refer to a single list of items)</li>
<li>A value that contains a simple set of property-value pairs (e.g&#x2e; <a href="qml-size.html">size</a> refers to a value with <code>width</code> and <code>height</code> attributes)</li>
</ul>
<p>When a variable or property holds a basic type and it is assigned to another variable or property, then a copy of the value is made. In JavaScript, this value is called a primitive value.</p>
<a name="supported-basic-types"></a>
<h2 id="supported-basic-types">Supported Basic Types</h2>
<p>Some basic types are supported by the engine by default and do not require an <a href="qtqml-syntax-imports.html">import statement</a> to be used, while others do require the client to import the module which provides them. All of the basic types listed below may be used as a <code>property</code> type in a QML document, with the following exceptions:</p>
<ul>
<li><code>list</code> must be used in conjunction with a QML object type</li>
<li><code>enumeration</code> cannot be used directly as the enumeration must be defined by a registered QML object type</li>
</ul>
<a name="basic-types-provided-by-the-qml-language"></a>
<h3 id="basic-types-provided-by-the-qml-language">Basic Types Provided By The QML Language</h3>
<p>The basic types supported natively in the QML language are listed below: <div class="table"><table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-bool.html">bool</a></p></td><td class="tblDescr"><p>Binary true/false value</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-double.html">double</a></p></td><td class="tblDescr"><p>Number with a decimal point, stored in double precision</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-enumeration.html">enumeration</a></p></td><td class="tblDescr"><p>Named enumeration value</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-int.html">int</a></p></td><td class="tblDescr"><p>Whole number, e.g&#x2e; 0, 10, or -20</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-list.html">list</a></p></td><td class="tblDescr"><p>List of QML objects</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-real.html">real</a></p></td><td class="tblDescr"><p>Number with a decimal point</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-string.html">string</a></p></td><td class="tblDescr"><p>Free form text string</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-url.html">url</a></p></td><td class="tblDescr"><p>Resource locator</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-var.html">var</a></p></td><td class="tblDescr"><p>Generic property type</p></td></tr>
</table></div>
</p>
<a name="basic-types-provided-by-qml-modules"></a>
<h3 id="basic-types-provided-by-qml-modules">Basic Types Provided By QML Modules</h3>
<p>QML modules may extend the QML language with more basic types. For example, the basic types provided by the <code>QtQuick</code> module are listed below: <div class="table"><table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-date.html">date</a></p></td><td class="tblDescr"><p>Date value</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-point.html">point</a></p></td><td class="tblDescr"><p>Value with x and y attributes</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-rect.html">rect</a></p></td><td class="tblDescr"><p>Value with x, y, width and height attributes</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-size.html">size</a></p></td><td class="tblDescr"><p>Value with width and height attributes</p></td></tr>
</table></div>
</p>
<p>The <a href="qml-qtqml-qt.html">Qt</a> global object provides useful functions for manipulating values of basic types.</p>
<p>Currently only QML modules which are provided by Qt may provide their own basic types, however this may change in future releases of Qt QML. In order to use types provided by a particular QML module, clients must import that module in their QML documents.</p>
<a name="property-change-behavior-for-basic-types"></a>
<h2 id="property-change-behavior-for-basic-types">Property Change Behavior for Basic Types</h2>
<p>Some basic types have properties: for example, the font type has <code>pixelSize</code>, <code>family</code> and <code>bold</code> properties. Unlike properties of <a href="qtqml-typesystem-topic.html#qml-object-types">object types</a>, properties of basic types do not provide their own property change signals. It is only possible to create a property change signal handler for the basic type property itself:</p>
<pre class="cpp">

  Text {
      <span class="comment">// invalid!</span>
      onFont<span class="operator">.</span>pixelSizeChanged: doSomething()

      <span class="comment">// also invalid!</span>
      font {
          onPixelSizeChanged: doSomething()
      }

      <span class="comment">// but this is ok</span>
      onFontChanged: doSomething()
  }

</pre>
<p>Be aware, however, that a property change signal for a basic type is emitted whenever <i>any</i> of its attributes have changed, as well as when the property itself changes. Take the following code, for example:</p>
<pre class="qml">



</pre>
<p>In contrast, properties of an <a href="qtqml-typesystem-topic.html#qml-object-types">object type</a> emit their own property change signals, and a property change signal handler for an object-type property is only invoked when the property is reassigned to a different object value.</p>
</div>
<p><b>See also </b><a href="qtqml-typesystem-topic.html">The QML Type System</a>.</p>
<!-- @@@qtqml-typesystem-basictypes.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 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>