Sophie

Sophie

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

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" />
<!-- qquickstate.cpp -->
  <title>State QML Type | Qt Quick 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="qtquick-index.html">Qt Quick</a></td><td ><a href="qtquick-qmlmodule.html">QML Types</a></td><td >State QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-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="#properties">Properties</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">State QML Type</h1>
<span class="subtitle"></span>
<!-- $$$State-brief -->
<p>Defines configurations of objects and properties. <a href="#details">More...</a></p>
<!-- @@@State -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr></table></div><ul>
<li><a href="qml-qtquick-state-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-state.html#changes-prop">changes</a></b></b> : list&lt;Change&gt;</li>
<li class="fn"><b><b><a href="qml-qtquick-state.html#extend-prop">extend</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-state.html#name-prop">name</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-state.html#when-prop">when</a></b></b> : bool</li>
</ul>
<!-- $$$State-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>A <i>state</i> is a set of batched changes from the default configuration.</p>
<p>All items have a default state that defines the default configuration of objects and property values. New states can be defined by adding State items to the <a href="qml-qtquick-item.html#states-prop">states</a> property to allow items to switch between different configurations. These configurations can, for example, be used to apply different sets of property values or execute different scripts.</p>
<p>The following example displays a single <a href="qml-qtquick-rectangle.html">Rectangle</a>. In the default state, the rectangle is colored black. In the &quot;clicked&quot; state, a <a href="qml-qtquick-propertychanges.html">PropertyChanges</a> object changes the rectangle's color to red. Clicking within the <a href="qml-qtquick-mousearea.html">MouseArea</a> toggles the rectangle's state between the default state and the &quot;clicked&quot; state, thus toggling the color of the rectangle between black and red.</p>
<pre class="qml">

  import QtQuick 2.0

  Rectangle {
      id: myRect
      width: 100; height: 100
      color: "black"

      MouseArea {
          id: mouseArea
          anchors.fill: parent
          onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked';
      }

      states: [
          State {
              name: "clicked"
              PropertyChanges { target: myRect; color: "red" }
          }
      ]
  }

</pre>
<p>Notice the default state is referred to using an empty string (&quot;&quot;).</p>
<p>States are commonly used together with <a href="qtquick-statesanimations-animations.html">Transitions</a> to provide animations when state changes occur.</p>
<p><b>Note: </b>Setting the state of an object from within another state of the same object is not allowed.</p><p><b>See also </b><a href="qtquick-animation-example.html#states">States example</a>, <a href="qtquick-statesanimations-states.html">Qt Quick States</a>, <a href="qtquick-statesanimations-animations.html">Transitions</a>, and Qt QML.</p>
<!-- @@@State -->
<h2>Property Documentation</h2>
<!-- $$$changes -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="changes-prop">
<td class="tblQmlPropNode"><p>
<a name="changes-prop"></a><span class="qmldefault">[default] </span><span class="name">changes</span> : <span class="type">list</span>&lt;<span class="type">Change</span>&gt;</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the changes to apply for this state</p>
<p>By default these changes are applied against the default state. If the state extends another state, then the changes are applied against the state being extended.</p>
</div></div><!-- @@@changes -->
<br/>
<!-- $$$extend -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="extend-prop">
<td class="tblQmlPropNode"><p>
<a name="extend-prop"></a><span class="name">extend</span> : <span class="type">string</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the state that this state extends.</p>
<p>When a state extends another state, it inherits all the changes of that state.</p>
<p>The state being extended is treated as the base state in regards to the changes specified by the extending state.</p>
</div></div><!-- @@@extend -->
<br/>
<!-- $$$name -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="name-prop">
<td class="tblQmlPropNode"><p>
<a name="name-prop"></a><span class="name">name</span> : <span class="type">string</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the name of the state.</p>
<p>Each state should have a unique name within its item.</p>
</div></div><!-- @@@name -->
<br/>
<!-- $$$when -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="when-prop">
<td class="tblQmlPropNode"><p>
<a name="when-prop"></a><span class="name">when</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds when the state should be applied.</p>
<p>This should be set to an expression that evaluates to <code>true</code> when you want the state to be applied. For example, the following <a href="qml-qtquick-rectangle.html">Rectangle</a> changes in and out of the &quot;hidden&quot; state when the <a href="qml-qtquick-mousearea.html">MouseArea</a> is pressed:</p>
<pre class="qml">

  Rectangle {
      id: myRect
      width: 100; height: 100
      color: "red"

      MouseArea { id: mouseArea; anchors.fill: parent }

      states: State {
          name: "hidden"; when: mouseArea.pressed
          PropertyChanges { target: myRect; opacity: 0 }
      }
  }

</pre>
<p>If multiple states in a group have <code>when</code> clauses that evaluate to <code>true</code> at the same time, the first matching state will be applied. For example, in the following snippet <code>state1</code> will always be selected rather than <code>state2</code> when sharedCondition becomes <code>true</code>.</p>
<pre class="qml">



</pre>
</div></div><!-- @@@when -->
<br/>
        </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>