Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 187

qt-mobility-doc-1.2.0-13.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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" />
<!-- poster.qdoc -->
  <title>Qt Mobility 1.2: QML Poster Example</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="http://qt.nokia.com/doc/4.7/all-examples.html">Examples</a></li>
<li>QML Poster Example</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<h1 class="title">QML Poster Example</h1>
<span class="subtitle"></span>
<!-- $$$declarative-connectivity/poster-description -->
<div class="descr"> <a name="details"></a>
<p>Files:</p>
<ul>
<li><a href="declarative-connectivity-poster-poster-qml.html">declarative-connectivity/poster/poster.qml</a></li>
<li><a href="declarative-connectivity-poster-qmlposter-cpp.html">declarative-connectivity/poster/qmlposter.cpp</a></li>
<li><a href="declarative-connectivity-poster-poster-pro.html">declarative-connectivity/poster/poster.pro</a></li>
<li><a href="declarative-connectivity-poster-poster-qrc.html">declarative-connectivity/poster/poster.qrc</a></li>
</ul>
<p>The QML Poster example displays the contents of specifically formated NDEF messages read from an NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one or more localized Text records.</p>
<p class="centerAlign"><img src="images/qml-poster-example.png" alt="" /></p><p>An NFC enabled poster can be a poster in a public place with an embedded NFC tag. A passerby may stop, read the text printed on the poster and become curious. She sees that the poster contains an NFC tag and holds her phone up to touch the area marked as the tag. The tag can then transfer additional data to the mobile device. The device can take whatever action the application thinks is necessary, from simply displaying text and links to opening links in the transferred data.</p>
<p>The example declares a <a href="qml-nearfield.html">NearField</a> element with id <i>nearfield</i>. This includes a <i>filter</i> constructed from two <a href="qml-ndeffilter.html">NdefFilter</a>s. The filters have the type specified by a string such as &quot;urn:nfc:wkt:U&quot;, which identifies the type as being an NFC <i>Well Known Type</i>, that is predefined, of &quot;U&quot; representing a URL. The other <a href="qml-ndeffilter.html">NdefFilter</a> element is for a Well Known Type of &quot;T&quot; (Text).</p>
<pre class="qml">         <span class="name">filter</span>: [
             <span class="type"><a href="qml-ndeffilter.html">NdefFilter</a></span> { <span class="name">type</span>: <span class="string">&quot;urn:nfc:wkt:U&quot;</span>; <span class="name">minimum</span>: <span class="number">1</span>; <span class="name">maximum</span>: <span class="number">1</span> },
             <span class="type"><a href="qml-ndeffilter.html">NdefFilter</a></span> { <span class="name">type</span>: <span class="string">&quot;urn:nfc:wkt:T&quot;</span>; <span class="name">minimum</span>: <span class="number">1</span> }
         ]</pre>
<p>The <a href="qml-nearfield.html">NearField</a> element has the properties of <a href="qml-nearfield.html#filter-prop">filter</a>, <a href="qml-nearfield.html#messageRecords-prop">messageRecords</a> and <a href="qml-nearfield.html#orderMatch-prop">orderMatch</a>. In this example the <i>filter</i> component contains the two <a href="qml-ndeffilter.html">NdefFilter</a> elements, the <i>orderMatch</i> property is not used in this example and the <i>messageRecords</i> property is a list of <a href="qml-ndefrecord.html">NdefRecord</a>s containing the results of the last read. When the signal <i>messageRecordsChanged()</i> is emitted the slot <i>onMessageRecordsChanged</i> will iterate through the <a href="qml-nearfield.html#messageRecords-prop">messageRecords</a> selecting particular types. After all records in the messageRecords list have been examined the state of the example is set to &quot;Show&quot; which displays the results.</p>
<pre class="qml">         <span class="name">onMessageRecordsChanged</span>: {
             <span class="name">posterText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">&quot;&quot;</span>;
             <span class="name">posterImage</span>.<span class="name">source</span> <span class="operator">=</span> <span class="string">&quot;&quot;</span>;
             <span class="name">posterUrl</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">&quot;&quot;</span>;

             var <span class="name">currentLocaleMatch</span> = <span class="name">NdefTextRecord</span>.<span class="name">LocaleMatchedNone</span>;
             var <span class="name">i</span>;
             <span class="keyword">for</span> (<span class="name">i</span> <span class="operator">=</span> <span class="number">0</span>; <span class="name">i</span> <span class="operator">&lt;</span> <span class="name">messageRecords</span>.<span class="name">length</span>; ++<span class="name">i</span>) {
                 <span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">recordType</span> <span class="operator">==</span> <span class="string">&quot;urn:nfc:wkt:T&quot;</span>) {
                     <span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">localeMatch</span> <span class="operator">&gt;</span> <span class="name">currentLocaleMatch</span>) {
                         <span class="name">currentLocaleMatch</span> <span class="operator">=</span> <span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">localeMatch</span>;
                         <span class="name">posterText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">text</span>;
                     }
                 } else <span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">recordType</span> <span class="operator">==</span> <span class="string">&quot;urn:nfc:wkt:U&quot;</span>) {
                     <span class="name">posterUrl</span>.<span class="name">text</span> <span class="operator">=</span> <span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">uri</span>;
                 } else <span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">recordType</span>.<span class="name">substr</span>(<span class="number">0</span>, <span class="number">19</span>) <span class="operator">==</span> <span class="string">&quot;urn:nfc:mime:image/&quot;</span>) {
                     <span class="name">posterImage</span>.<span class="name">source</span> <span class="operator">=</span> <span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">uri</span>;
                 }
             }

             <span class="name">root</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">&quot;show&quot;</span>;
         }</pre>
</div>
<!-- @@@declarative-connectivity/poster -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used 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.</p>
</div>
</body>
</html>