IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Changes to Qt NFC

Migrate Qt NFC to Qt 6.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Changes to Qt NFC

Qt 6 is a result of the conscious effort to make the framework more efficient and easy to use.

We try to maintain binary and source compatibility for all the public APIs in each release. But some changes were inevitable in an effort to make Qt a better framework.

In this topic we summarize those changes in Qt NFC, and provide guidance to handle them.

New Features and Methods

 

Added QNdefRecord::clear()

Use this method to clear an NDEF record.

Added QNdefFilter::match()

Use this method to check if a QNdefMessage matches the given filter. The method returns true in case of successful match and false otherwise.

Extended QNearFieldTarget::Type

The enum was extended with two more types:

Changes in the Features and Methods

 

Renamed QNearFieldManager::isAvailable()

The QNearFieldManager::isAvailable() was renamed to QNearFieldManager::isEnabled().

Added access method argument to QNearFieldManager::isSupported

The accessMethod argument allows to check if a specific feature is supported. This is relevant because different platforms or versions of operating systems can support different options.

Added access method argument to QNearFieldManager::startTargetDetection

The accessMethod argument allows to scan for NFC tags with the given access method.

Changed QNdefNfcSmartPosterRecord::typeInfo from QByteArray to QString

According to NDEF Smart Poster specification, the type is a UTF-8 formatted string. This affects the QNdefNfcSmartPosterRecord::typeInfo() and QNdefNfcSmartPosterRecord::setTypeInfo() methods.

Updated return type of QNdefFilter::appendRecord

QNdefFilter::appendRecord now performs a basic validation of input parameters and returns a boolean value indicating if the record is appended to the filter or not.

Removed Features and Methods

 

Removed QNearFieldTarget::url

The method was never implemented in the existing subclasses of QNearFieldTarget.

Removed QNearFieldTarget::sendCommands

In Qt 5, the method was not very helpful because it didn't provide a way to track the results of intermediate commands. Normally, an additional command needs to be sent only when the previous command is successfully executed.

The correct approach would be to manually create a queue of commands, use QNearFieldTarget::sendCommand to send a command and QNearFieldTarget::requestCompleted or QNearFieldTarget::error to handle the results of each command individually.

Removed QNearFieldTarget::keepConnection

The methods QNearFieldTarget::keepConnection() and QNearFieldTarget::setKeepConnection() were removed. Keeping the connection is the default behavior for now.

Removed QNearFieldTarget::isProcessingCommand

The method was never implemented and always returned false.

Made QNearFieldTarget::setResponseForRequest private API

The method should not be exposed as a public API. Use QNearFieldTarget::ndefMessageRead or QNearFieldTarget::requestResponse to read the data from an NFC tag.

Removed QNearFieldTarget::handleResponse

The method was removed as it just forwarded the call to QNearFieldManager::setResponseForRequest, which became private API.

Made QNearFieldTarget::reportError private API

A QNearFieldTarget::error signal can be used instead.

Removed QNearFieldTarget::ndefMessagesWritten signal

The QNearFieldTarget::requestCompleted signal is used for both NDEF messages and custom commands. The id parameter can be used to check which request is actually completed.

Removed QNearFieldManager::(un)registerNdefMessageHandler

The methods QNearFieldTarget::registerNdefMessageHandler and QNearFieldTarget::unregisterNdefMessageHandler were removed.

Use QNearFieldTarget::ndefMessageRead() and QNdefFilter::match() to detect the NDEF messages and filter the required ones.

The application can still be automatically started once the NDEF Tag is touched. The Annotated URL example shows how to achieve it on Android.

Removed QNearFieldManager::TargetAccessModes

The TargetAccessModes enum was removed together with the getter and setter methods (QNearFieldManager::setTargetAccessModes() and QNearFieldManager::targetAccessModes()).

The feature is not supported on Android and iOS platforms.

Removed QNearFieldShareManager and QNearFieldShareTarget

File sharing via NFC is deprecated on Android in API 29. Other technologies should be used instead.

Removed QML API

The support for QML API is discontinued.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+