Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 601

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDeclarativePropertyMap Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDeclarativePropertyMap Class Reference<br /><sup><sup>[<a href="qtdeclarative.html">QtDeclarative</a> module]</sup></sup></h1><p>The QDeclarativePropertyMap class allows you to set key-value
pairs that can be used in QML bindings. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdeclarativepropertymap.html#QDeclarativePropertyMap">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qdeclarativepropertymap.html#clear">clear</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativepropertymap.html#contains">contains</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" />int <b><a href="qdeclarativepropertymap.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativepropertymap.html#insert">insert</a></b> (<i>self</i>, QString&#160;<i>key</i>, QVariant&#160;<i>value</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativepropertymap.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qdeclarativepropertymap.html#keys">keys</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdeclarativepropertymap.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qdeclarativepropertymap.html#value">value</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QVariant <b><a href="qdeclarativepropertymap.html#__getitem__">__getitem__</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" /> <b><a href="qdeclarativepropertymap.html#__len__">__len__</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdeclarativepropertymap.html#valueChanged">valueChanged</a></b> (const QString&amp;,const QVariant&amp;)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDeclarativePropertyMap class allows you to set key-value
pairs that can be used in QML bindings.</p>
<p>QDeclarativePropertyMap provides a convenient way to expose
domain data to the UI layer. The following example shows how you
might declare data in C++ and then access it in QML.</p>
<p>In the C++ file:</p>
<pre class="cpp">
 <span class="comment">// create our data</span>
 <span class="type">QDeclarativePropertyMap</span> ownerData;
 ownerData<span class="operator">.</span><a href="qdeclarativepropertymap.html#insert">insert</a>(<span class="string">"name"</span><span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(<span class="type"><a href="qstring.html">QString</a></span>(<span class="string">"John Smith"</span>)));
 ownerData<span class="operator">.</span><a href="qdeclarativepropertymap.html#insert">insert</a>(<span class="string">"phone"</span><span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(<span class="type"><a href="qstring.html">QString</a></span>(<span class="string">"555-5555"</span>)));

 <span class="comment">// expose it to the UI layer</span>
 <span class="type"><a href="qdeclarativeview.html">QDeclarativeView</a></span> view;
 <span class="type"><a href="qdeclarativecontext.html">QDeclarativeContext</a></span> <span class="operator">*</span>ctxt <span class="operator">=</span> view<span class="operator">.</span>rootContext();
 ctxt<span class="operator">-</span><span class="operator">&gt;</span>setContextProperty(<span class="string">"owner"</span><span class="operator">,</span> <span class="operator">&amp;</span>ownerData);

 view<span class="operator">.</span>setSource(<span class="type"><a href="qurl.html">QUrl</a></span><span class="operator">.</span>fromLocalFile(<span class="string">"main.qml"</span>));
 view<span class="operator">.</span>show();
</pre>
<p>Then, in <tt>main.qml</tt>:</p>
<pre class="cpp">
 Text { text: owner<span class="operator">.</span>name <span class="operator">+</span> <span class="string">" "</span> <span class="operator">+</span> owner<span class="operator">.</span>phone }
</pre>
<p>The binding is dynamic - whenever a key's value is updated,
anything bound to that key will be updated as well.</p>
<p>To detect value changes made in the UI layer you can connect to
the <a href="qdeclarativepropertymap.html#valueChanged">valueChanged</a>()
signal. However, note that <a href="qdeclarativepropertymap.html#valueChanged">valueChanged</a>() is
<b>NOT</b> emitted when changes are made by calling <a href="qdeclarativepropertymap.html#insert">insert</a>() or <a href="qdeclarativepropertymap.html#clear">clear</a>() - it is only
emitted when a value is updated from QML.</p>
<p><b>Note:</b> It is not possible to remove keys from the map;
once a key has been added, you can only modify or clear its
associated value.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDeclarativePropertyMap" />QDeclarativePropertyMap.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a bindable map with parent object <i>parent</i>.</p>


<h3 class="fn"><a name="clear" />QDeclarativePropertyMap.clear (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Clears the value (if any) associated with <i>key</i>.</p>


<h3 class="fn"><a name="contains" />bool QDeclarativePropertyMap.contains (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Returns true if the map contains <i>key</i>.</p>
<p><b>See also</b> <a href="qdeclarativepropertymap.html#size">size</a>().</p>


<h3 class="fn"><a name="count" />int QDeclarativePropertyMap.count (<i>self</i>)</h3><p>This is an overloaded function.</p>
<p>Same as <a href="qdeclarativepropertymap.html#size">size</a>().</p>


<h3 class="fn"><a name="insert" />QDeclarativePropertyMap.insert (<i>self</i>, QString&#160;<i>key</i>, QVariant&#160;<i>value</i>)</h3><p>Sets the value associated with <i>key</i> to <i>value</i>.</p>
<p>If the key doesn't exist, it is automatically created.</p>


<h3 class="fn"><a name="isEmpty" />bool QDeclarativePropertyMap.isEmpty (<i>self</i>)</h3><p>Returns true if the map contains no keys; otherwise returns
false.</p>
<p><b>See also</b> <a href="qdeclarativepropertymap.html#size">size</a>().</p>


<h3 class="fn"><a name="keys" />QStringList QDeclarativePropertyMap.keys (<i>self</i>)</h3><p>Returns the list of keys.</p>
<p>Keys that have been cleared will still appear in this list, even
though their associated values are invalid <a href="qtwebkit-bridge.html#qvariants">QVariants</a>.</p>


<h3 class="fn"><a name="size" />int QDeclarativePropertyMap.size (<i>self</i>)</h3><p>Returns the number of keys in the map.</p>
<p><b>See also</b> <a href="qdeclarativepropertymap.html#isEmpty">isEmpty</a>() and <a href="qdeclarativepropertymap.html#count">count</a>().</p>


<h3 class="fn"><a name="value" />QVariant QDeclarativePropertyMap.value (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Returns the value associated with <i>key</i>.</p>
<p>If no value has been set for this key (or if the value has been
cleared), an invalid <a href="qvariant.html">QVariant</a> is
returned.</p>


<h3 class="fn"><a name="__getitem__" />QVariant QDeclarativePropertyMap.__getitem__ (<i>self</i>, QString&#160;<i>key</i>)</h3><h3 class="fn"><a name="__len__" /> QDeclarativePropertyMap.__len__ (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="valueChanged" />void valueChanged (const QString&amp;,const QVariant&amp;)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever one of the values in the map is
changed. <i>key</i> is the key corresponding to the <i>value</i>
that was changed.</p>
<p><b>Note:</b> valueChanged() is <b>NOT</b> emitted when changes
are made by calling <a href="qdeclarativepropertymap.html#insert">insert</a>() or <a href="qdeclarativepropertymap.html#clear">clear</a>() - it is only
emitted when a value is updated from QML.</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>