/usr/share/qt5/doc/qtqml/qml-qtqml-binding.html is in qtdeclarative5-doc-html 5.2.1-3ubuntu15.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qqmlbind.cpp -->
<title>Binding | QtQml 5.2</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.2</li>
<li><a href="qtqml-index.html">Qt QML</a></li>
<li><a href="qtqml-qmlmodule.html">QML Types</a></li>
<li>Binding</li>
<li id="buildversion">
Qt 5.2.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<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="#binding-to-an-inaccessible-property">Binding to an inaccessible property</a></li>
<li class="level2"><a href="#single-branch-conditional-binding">"Single-branch" conditional binding</a></li>
</ul>
</div>
<h1 class="title">Binding</h1>
<span class="subtitle"></span>
<!-- $$$Binding-brief -->
<p>Enables the arbitrary creation of property bindings <a href="#details">More...</a></p>
<!-- @@@Binding -->
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> </b><tt>import QtQml 2.2</tt></td></tr></table><ul>
<li><a href="qml-qtqml-binding-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtqml-binding.html#property-prop">property</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtqml-binding.html#target-prop">target</a></b></b> : Object</li>
<li class="fn"><b><b><a href="qml-qtqml-binding.html#value-prop">value</a></b></b> : any</li>
<li class="fn"><b><b><a href="qml-qtqml-binding.html#when-prop">when</a></b></b> : bool</li>
</ul>
<!-- $$$Binding-description -->
<a name="details"></a>
<h2>Detailed Description</h2>
<a name="binding-to-an-inaccessible-property"></a>
<h2>Binding to an inaccessible property</h2>
<p>Sometimes it is necessary to bind to a property of an object that wasn't directly instantiated by QML - generally a property of a class exported to QML by C++. In these cases, regular property binding doesn't work. Binding allows you to bind any value to any property.</p>
<p>For example, imagine a C++ application that maps an "app.enteredText" property into QML. You could use Binding to update the enteredText property like this.</p>
<pre class="cpp">TextEdit { id: myTextField; text: <span class="string">"Please type here..."</span> }
Binding { target: app; property: <span class="string">"enteredText"</span>; value: myTextField<span class="operator">.</span>text }</pre>
<p>Whenever the text in the TextEdit is updated, the C++ property will be updated also.</p>
<a name="single-branch-conditional-binding"></a>
<h2>"Single-branch" conditional binding</h2>
<p>In some circumstances you may want to control the value of a property only when a certain condition is true (and relinquish control in all other circumstances). This often isn't possible to accomplish with a direct binding, as you need to supply values for all possible branches.</p>
<pre class="cpp"><span class="comment">// produces warning: "Unable to assign [undefined] to double value"</span>
value: <span class="keyword">if</span> (mouse<span class="operator">.</span>pressed) mouse<span class="operator">.</span>mouseX</pre>
<p>The above example will produce a warning whenever we release the mouse, as the value of the binding is undefined when the mouse isn't pressed. We can use the Binding type to rewrite the above code and avoid the warning.</p>
<pre class="qml">Binding on value {
when: mouse.pressed
value: mouse.mouseX
}</pre>
<p>The Binding type will also restore any previously set direct bindings on the property. In that sense, it functions much like a simplified State.</p>
<pre class="qml"><span class="comment">// this is equivalent to the above Binding</span>
<span class="type">State</span> {
<span class="name">name</span>: <span class="string">"pressed"</span>
<span class="name">when</span>: <span class="name">mouse</span>.<span class="name">pressed</span>
<span class="type">PropertyChanges</span> {
<span class="name">target</span>: <span class="name">obj</span>
<span class="name">value</span>: <span class="name">mouse</span>.<span class="name">mouseX</span>
}
}</pre>
<p>If the binding target or binding property is changed, the bound value is immediately pushed onto the new target.</p>
<p><b>See also </b><a href="qtqml-index.html">Qt QML</a>.</p>
<!-- @@@Binding -->
<h2>Property Documentation</h2>
<!-- $$$property -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="property-prop"></a><span class="name">property</span> : <span class="type"><a href="qml-string.html">string</a></span></p></td></tr></table></div><div class="qmldoc"><p>The property to be updated.</p>
</div></div><!-- @@@property -->
<br/>
<!-- $$$target -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><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 class="qmldoc"><p>The object to be updated.</p>
</div></div><!-- @@@target -->
<br/>
<!-- $$$value -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="value-prop"></a><span class="name">value</span> : <span class="type">any</span></p></td></tr></table></div><div class="qmldoc"><p>The value to be set on the target object and property. This can be a constant (which isn't very useful), or a bound expression.</p>
</div></div><!-- @@@value -->
<br/>
<!-- $$$when -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="when-prop"></a><span class="name">when</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds when the binding is active. This should be set to an expression that evaluates to true when you want the binding to be active.</p>
<pre class="cpp">Binding {
target: contactName; property: <span class="char">'text'</span>
value: name; when: list<span class="operator">.</span>ListView<span class="operator">.</span>isCurrentItem
}</pre>
<p>When the binding becomes inactive again, any direct bindings that were previously set on the property will be restored.</p>
</div></div><!-- @@@when -->
<br/>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its
subsidiaries. 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> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|