summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-02 13:56:50 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-06 09:17:50 +0000
commit5e8994a4fa83f4c2795978f8b9ae893cefc69160 (patch)
tree071e3a2a68ec818edcb9010a39dfbe642d88772c /examples
parent3e4236996d0d961bb91d30eff10e9b2aa8b7d4a7 (diff)
Make it more obvious what tags the NFC poster example expects.
Task-number: QTBUG-53616 Change-Id: Ie3a87abc61100ac8fe0a5b671725f54ae28e1501 Reviewed-by: Martin Smith <martin.smith@theqtcompany.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/nfc/poster/doc/images/qml-poster-example.pngbin5110 -> 7946 bytes
-rw-r--r--examples/nfc/poster/doc/src/poster.qdoc21
-rw-r--r--examples/nfc/poster/poster.qml14
3 files changed, 33 insertions, 2 deletions
diff --git a/examples/nfc/poster/doc/images/qml-poster-example.png b/examples/nfc/poster/doc/images/qml-poster-example.png
index d3ead72e..8ed2292c 100644
--- a/examples/nfc/poster/doc/images/qml-poster-example.png
+++ b/examples/nfc/poster/doc/images/qml-poster-example.png
Binary files differ
diff --git a/examples/nfc/poster/doc/src/poster.qdoc b/examples/nfc/poster/doc/src/poster.qdoc
index a569f47a..26320f56 100644
--- a/examples/nfc/poster/doc/src/poster.qdoc
+++ b/examples/nfc/poster/doc/src/poster.qdoc
@@ -31,7 +31,7 @@
\brief A QML example about reading and displaying NFC Data Exchange Format (NDEF) messages.
The QML Poster example displays the contents of specifically formatted NFC Data
-Exchange Format (NDEF) messages read from an NFC Tag. The NDEF message should
+Exchange Format (NDEF) messages read from an NFC Tag. The NDEF message must
contain a URI record, an optional \c image/* MIME record, and one or more
localized Text records.
@@ -39,5 +39,24 @@ localized Text records.
\include examples-run.qdocinc
+\section1 Applying NDEF Filters
+
+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
+\l NearField type's filter property. The property accepts a list of \l NdefFilter objects.
+
+\snippet poster/poster.qml QML NDEF filtering
+
+\section1 Processing Found NDEF Messages
+
+Once an appropriate tag is found, the \l NearField::messageRecords property reflects the content.
+It transports the list of found NDEF records. The QML snippet below
+demonstrates how these records can be accessed:
+
+\snippet poster/poster.qml messageRecordsChanged 1
+\snippet poster/poster.qml messageRecordsChanged 2
+\snippet poster/poster.qml messageRecordsChanged 3
+
\sa {Qt NFC}
*/
diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml
index a70a998b..d57ed5d9 100644
--- a/examples/nfc/poster/poster.qml
+++ b/examples/nfc/poster/poster.qml
@@ -62,13 +62,18 @@ Rectangle {
}
}
+ //! [QML NDEF filtering]
filter: [
NdefFilter { type: "U"; typeNameFormat: NdefRecord.NfcRtd; maximum: 1 },
NdefFilter { type: "T"; typeNameFormat: NdefRecord.NfcRtd },
NdefFilter { typeNameFormat: NdefRecord.Mime; minimum: 0; maximum: 1 }
]
+ //! [QML NDEF filtering]
+
+ //! [messageRecordsChanged 1]
onMessageRecordsChanged: {
+ //! [messageRecordsChanged 1]
posterText.text = "";
posterImage.source = "";
posterUrl.text = "";
@@ -76,6 +81,7 @@ Rectangle {
var currentLocaleMatch = NdefTextRecord.LocaleMatchedNone;
var i;
var found = false;
+ //! [messageRecordsChanged 2]
for (i = 0; i < messageRecords.length; ++i) {
switch (messageRecords[i].typeNameFormat) {
case NdefRecord.NfcRtd:
@@ -102,18 +108,24 @@ Rectangle {
if (!found)
console.warn("Unknown NFC tag detected. Cannot display content.")
}
+ //! [messageRecordsChanged 2]
root.state = "show";
+ //! [messageRecordsChanged 3]
}
+ //! [messageRecordsChanged 3]
}
Text {
id: touchText
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
- text: "Touch an NFC tag"
+ text: "Touch an NFC tag with at least one Text and one URI record."
font.bold: true
font.pointSize: 18
+ wrapMode: Text.WordWrap
+ width: root.width*0.75
+ horizontalAlignment: Text.AlignHCenter
}
Image {