Sophie

Sophie

distrib > Mageia > 6 > i586 > by-pkgid > 2cba8df17162abb32fcb8e6852f3eacc > files > 912

qtdeclarative5-doc-5.9.4-1.mga6.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" />
<!-- qquickpropertychanges.cpp -->
  <title>PropertyChanges QML Type | Qt Quick 5.9</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.9</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td ><a href="qtquick-qmlmodule.html">QML Types</a></td><td >PropertyChanges QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 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="#details">Detailed Description</a></li>
<li class="level2"><a href="#resetting-property-values">Resetting Property Values</a></li>
<li class="level2"><a href="#immediate-property-changes-in-transitions">Immediate Property Changes in Transitions</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">PropertyChanges QML Type</h1>
<span class="subtitle"></span>
<!-- $$$PropertyChanges-brief -->
<p>Describes new property bindings or values for a state. <a href="#details">More...</a></p>
<!-- @@@PropertyChanges -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick 2.7</td></tr></table></div><ul>
<li><a href="qml-qtquick-propertychanges-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-propertychanges.html#explicit-prop">explicit</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-propertychanges.html#restoreEntryValues-prop">restoreEntryValues</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-propertychanges.html#target-prop">target</a></b></b> : Object</li>
</ul>
<!-- $$$PropertyChanges-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p><a href="qml-qtquick-propertychanges.html">PropertyChanges</a> is used to define the property values or bindings in a <a href="qml-qtquick-state.html">State</a>. This enables an item's property values to be changed when it <a href="qtquick-statesanimations-states.html">changes between states</a>.</p>
<p>To create a <a href="qml-qtquick-propertychanges.html">PropertyChanges</a> object, specify the <a href="qml-qtquick-propertychanges.html#target-prop">target</a> item whose properties are to be modified, and define the new property values or bindings. For example:</p>
<pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">id</span>: <span class="name">container</span>
      <span class="name">width</span>: <span class="number">300</span>; <span class="name">height</span>: <span class="number">300</span>

      <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
          <span class="name">id</span>: <span class="name">rect</span>
          <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
          <span class="name">color</span>: <span class="string">&quot;red&quot;</span>

          <span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
             <span class="name">id</span>: <span class="name">mouseArea</span>
             <span class="name">anchors</span>.fill: <span class="name">parent</span>
          }

          <span class="name">states</span>: <span class="name">State</span> {
             <span class="name">name</span>: <span class="string">&quot;resized&quot;</span>; <span class="name">when</span>: <span class="name">mouseArea</span>.<span class="name">pressed</span>
             <span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">rect</span>; <span class="name">color</span>: <span class="string">&quot;blue&quot;</span>; <span class="name">height</span>: <span class="name">container</span>.<span class="name">height</span> }
          }
      }
  }

</pre>
<p>When the mouse is pressed, the <a href="qml-qtquick-rectangle.html">Rectangle</a> changes to the <i>resized</i> state. In this state, the <a href="qml-qtquick-propertychanges.html">PropertyChanges</a> object sets the rectangle's color to blue and the <code>height</code> value to that of <code>container.height</code>.</p>
<p>Note this automatically binds <code>rect.height</code> to <code>container.height</code> in the <i>resized</i> state. If a property binding should not be established, and the height should just be set to the value of <code>container.height</code> at the time of the state change, set the <a href="qml-qtquick-propertychanges.html#explicit-prop">explicit</a> property to <code>true</code>.</p>
<p>A <a href="qml-qtquick-propertychanges.html">PropertyChanges</a> object can also override the default signal handler for an object to implement a signal handler specific to the new state:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> {
      <span class="name">target</span>: <span class="name">myMouseArea</span>
      <span class="name">onClicked</span>: <span class="name">doSomethingDifferent</span>()
  }

</pre>
<p><b>Note: </b><a href="qml-qtquick-propertychanges.html">PropertyChanges</a> can be used to change anchor margins, but not other anchor values; use <a href="qml-qtquick-anchorchanges.html">AnchorChanges</a> for this instead. Similarly, to change an <a href="qml-qtquick-item.html">Item</a>'s <a href="qml-qtquick-item.html#parent-prop">parent</a> value, use <a href="qml-qtquick-parentchange.html">ParentChange</a> instead.</p><a name="resetting-property-values"></a>
<h3 >Resetting Property Values</h3>
<p>The <code>undefined</code> value can be used to reset the property value for a state. In the following example, when <code>myText</code> changes to the <i>widerText</i> state, its <code>width</code> property is reset, giving the text its natural width and displaying the whole string on a single line.</p>
<pre class="qml">

  <span class="type"><a href="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">200</span>

      <span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
          <span class="name">id</span>: <span class="name">myText</span>
          <span class="name">width</span>: <span class="number">50</span>
          <span class="name">wrapMode</span>: <span class="name">Text</span>.<span class="name">WordWrap</span>
          <span class="name">text</span>: <span class="string">&quot;a text string that is longer than 50 pixels&quot;</span>

          <span class="name">states</span>: <span class="name">State</span> {
              <span class="name">name</span>: <span class="string">&quot;widerText&quot;</span>
              <span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">myText</span>; <span class="name">width</span>: <span class="name">undefined</span> }
          }
      }

      <span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
          <span class="name">anchors</span>.fill: <span class="name">parent</span>
          <span class="name">onClicked</span>: <span class="name">myText</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">&quot;widerText&quot;</span>
      }
  }

</pre>
<a name="immediate-property-changes-in-transitions"></a>
<h3 >Immediate Property Changes in Transitions</h3>
<p>When <a href="qtquick-statesanimations-animations.html">Transitions</a> are used to animate state changes, they animate properties from their values in the current state to those defined in the new state (as defined by <a href="qml-qtquick-propertychanges.html">PropertyChanges</a> objects). However, it is sometimes desirable to set a property value <i>immediately</i> during a <a href="qmlexampletoggleswitch.html#transition">Transition</a>, without animation; in these cases, the <a href="qml-qtquick-propertyaction.html">PropertyAction</a> type can be used to force an immediate property change.</p>
<p>See the <a href="qml-qtquick-propertyaction.html">PropertyAction</a> documentation for more details.</p>
<p><b>Note: </b>The <a href="qml-qtquick-item.html#visible-prop">visible</a> and <a href="qml-qtquick-item.html#enabled-prop">enabled</a> properties of <a href="qml-qtquick-item.html">Item</a> do not behave exactly the same as other properties in <a href="qml-qtquick-propertychanges.html">PropertyChanges</a>. Since these properties can be changed implicitly through their parent's state, they should be set explicitly in all <a href="qml-qtquick-propertychanges.html">PropertyChanges</a>. An item will still not be enabled/visible if one of its parents is not enabled or visible.</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>, and Qt QML.</p>
<!-- @@@PropertyChanges -->
<h2>Property Documentation</h2>
<!-- $$$explicit -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="explicit-prop">
<td class="tblQmlPropNode"><p>
<a name="explicit-prop"></a><span class="name">explicit</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If explicit is set to true, any potential bindings will be interpreted as once-off assignments that occur when the state is entered.</p>
<p>In the following example, the addition of explicit prevents <code>myItem.width</code> from being bound to <code>parent.width</code>. Instead, it is assigned the value of <code>parent.width</code> at the time of the state change.</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> {
      <span class="name">target</span>: <span class="name">myItem</span>
      <span class="name">explicit</span>: <span class="number">true</span>
      <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
  }

</pre>
<p>By default, explicit is false.</p>
</div></div><!-- @@@explicit -->
<br/>
<!-- $$$restoreEntryValues -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="restoreEntryValues-prop">
<td class="tblQmlPropNode"><p>
<a name="restoreEntryValues-prop"></a><span class="name">restoreEntryValues</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds whether the previous values should be restored when leaving the state.</p>
<p>The default value is <code>true</code>. Setting this value to <code>false</code> creates a temporary state that has permanent effects on property values.</p>
</div></div><!-- @@@restoreEntryValues -->
<br/>
<!-- $$$target -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="target-prop">
<td class="tblQmlPropNode"><p>
<a name="target-prop"></a><span class="name">target</span> : <span class="type">Object</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the object which contains the properties to be changed.</p>
</div></div><!-- @@@target -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 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>