NdefEditor: do not clear the existing message before reading

The read operation can be cancelled, or might fail for some reason.
In this case, the user does not expect the existing entries to be
deleted, so do not clear the message before reading.

If the read is successful, the existing message is replaced by the
new one, so no action is required here.

Update the example documentation to clarify this behavior.

Amends 115b4d947a.

Fixes: QTBUG-120410
Pick-to: 6.5
Change-Id: Ibaf00fb3c661abcc39b5d758e57ee5a837c0e270
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit b55674cbab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ee3e3cfc26)
This commit is contained in:
Ivan Solovev 2024-01-02 12:17:52 +01:00 committed by Qt Cherry-pick Bot
parent 618e56cc2c
commit 23bdae7d62
2 changed files with 7 additions and 1 deletions

View File

@ -204,7 +204,6 @@ ApplicationWindow {
}
function readTag() {
messageModel.clearMessage()
window.targetDetectedAction = MainWindow.ReadMessage
nfcManager.startTargetDetection()
communicationOverlay.title = qsTr("Read Tag")

View File

@ -11,6 +11,13 @@ The NDEF Editor example reads and writes NFC Data Exchange Format
(NDEF) messages to NFC Forum Tags. NDEF messages can be composed by
adding text and URI records. Records can be deleted by swiping them to the left.
Press \b {Write to Tag} to write the records to an NFC tag.
Press \b {Read Tag} to read the contents of an NFC tag. A successful read of an
NFC tag replaces the manually added records with the NDEF message from the tag.
If the read operation was cancelled or failed, the NDEF message remains
unchanged.
\image ndefeditor.png
\sa {Qt NFC}