/usr/share/qt5/doc/qtnfc/qtnfc-poster-example.html is in qtconnectivity5-doc-html 5.7.1~20161021-2.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- poster.qdoc -->
<title>QML Poster Example | Qt NFC 5.7</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
window.onload = function(){document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");};
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.7</td><td ><a href="qtnfc-index.html">Qt NFC</a></td><td >QML Poster Example</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.7.1 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="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#applying-ndef-filters">Applying NDEF Filters</a></li>
<li class="level1"><a href="#processing-found-ndef-messages">Processing Found NDEF Messages</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QML Poster Example</h1>
<span class="subtitle"></span>
<!-- $$$poster-description -->
<div class="descr"> <a name="details"></a>
<p>The QML Poster example displays the contents of specifically formatted NFC Data Exchange Format (NDEF) messages read from an NFC Tag. The NDEF message must contain a URI record, an optional <code>image/*</code> MIME record, and one or more localized Text records.</p>
<p class="centerAlign"><img src="images/qml-poster-example.png" alt="" /></p><a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="applying-ndef-filters"></a>
<h2 id="applying-ndef-filters">Applying NDEF Filters</h2>
<p>The example is designed to display the content of a very specific type of NFC tag. The tag must contain at least one URI record and one text record. If those two record types do not exist, nothing will happen. Such filtering is applied via the <a href="qml-qtnfc-nearfield.html">NearField</a> type's filter property. The property accepts a list of <a href="qml-qtnfc-ndeffilter.html">NdefFilter</a> objects.</p>
<pre class="qml">
<span class="name">filter</span>: [
<span class="type">NdefFilter</span> { <span class="name">type</span>: <span class="string">"U"</span>; <span class="name">typeNameFormat</span>: <span class="name">NdefRecord</span>.<span class="name">NfcRtd</span>; <span class="name">maximum</span>: <span class="number">1</span> },
<span class="type">NdefFilter</span> { <span class="name">type</span>: <span class="string">"T"</span>; <span class="name">typeNameFormat</span>: <span class="name">NdefRecord</span>.<span class="name">NfcRtd</span> },
<span class="type">NdefFilter</span> { <span class="name">typeNameFormat</span>: <span class="name">NdefRecord</span>.<span class="name">Mime</span>; <span class="name">minimum</span>: <span class="number">0</span>; <span class="name">maximum</span>: <span class="number">1</span> }
]
</pre>
<a name="processing-found-ndef-messages"></a>
<h2 id="processing-found-ndef-messages">Processing Found NDEF Messages</h2>
<p>Once an appropriate tag is found, the <a href="qml-qtnfc-nearfield.html#messageRecords-prop">NearField::messageRecords</a> property reflects the content. It transports the list of found NDEF records. The QML snippet below demonstrates how these records can be accessed:</p>
<pre class="qml">
<span class="name">onMessageRecordsChanged</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"><</span> <span class="name">messageRecords</span>.<span class="name">length</span>; ++<span class="name">i</span>) {
<span class="keyword">switch</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">typeNameFormat</span>) {
<span class="keyword">case</span> <span class="name">NdefRecord</span>.<span class="name">NfcRtd</span>:
<span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">type</span> <span class="operator">===</span> <span class="string">"T"</span>) {
<span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">localeMatch</span> <span class="operator">></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>;
<span class="name">found</span> <span class="operator">=</span> <span class="number">true</span>;
}
} <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">type</span> <span class="operator">===</span> <span class="string">"U"</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>;
<span class="name">found</span> <span class="operator">=</span> <span class="number">true</span>;
}
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="name">NdefRecord</span>.<span class="name">Mime</span>:
<span class="keyword">if</span> (<span class="name">messageRecords</span>[<span class="name">i</span>].<span class="name">type</span>.<span class="name">indexOf</span>(<span class="string">"image/"</span>) <span class="operator">===</span> <span class="number">0</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">found</span> <span class="operator">=</span> <span class="number">true</span>;
}
<span class="keyword">break</span>;
}
<span class="keyword">if</span> (!<span class="name">found</span>)
<span class="name">console</span>.<span class="name">warn</span>(<span class="string">"Unknown NFC tag detected. Cannot display content."</span>)
}
}
</pre>
<p>Files:</p>
<ul>
<li><a href="qtnfc-poster-poster-qml.html">poster/poster.qml</a></li>
<li><a href="qtnfc-poster-qmlposter-cpp.html">poster/qmlposter.cpp</a></li>
<li><a href="qtnfc-poster-poster-pro.html">poster/poster.pro</a></li>
<li><a href="qtnfc-poster-poster-qrc.html">poster/poster.qrc</a></li>
</ul>
</div>
<p><b>See also </b><a href="qtnfc-index.html">Qt NFC</a>.</p>
<!-- @@@poster -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2016 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>
|