Qt 6 是努力使框架更高效,且更易于使用的结果。
为兼容每个发行的所有公共 API,我们试着维护二进制和源代码。但是,为使 Qt 成为更优框架,一些改变是不可避免的。
In this topic we summarize those changes in Qt NFC, and provide guidance to handle them.
Use this method to clear an NDEF record.
Use this method to check if a
QNdefMessage
matches the given filter. The method returns
true
in case of successful match and
false
否则。
The enum was extended with two more types:
The
QNearFieldManager::isAvailable()
was renamed to
QNearFieldManager::isEnabled
().
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.
The
accessMethod
argument allows to scan for NFC tags with the given access method.
According to NDEF Smart Poster specification, the type is a UTF-8 formatted string. This affects the QNdefNfcSmartPosterRecord::typeInfo () 和 QNdefNfcSmartPosterRecord::setTypeInfo () 方法。
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.
The method was never implemented in the existing subclasses of QNearFieldTarget .
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.
方法
QNearFieldTarget::keepConnection()
and
QNearFieldTarget::setKeepConnection()
were removed. Keeping the connection is the default behavior for now.
The method was never implemented and always returned
false
.
The method should not be exposed as a public API. Use QNearFieldTarget::ndefMessageRead or QNearFieldTarget::requestResponse to read the data from an NFC tag.
The method was removed as it just forwarded the call to
QNearFieldManager::setResponseForRequest
, which became private API.
A QNearFieldTarget::error signal can be used instead.
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.
方法
QNearFieldTarget::registerNdefMessageHandler
and
QNearFieldTarget::unregisterNdefMessageHandler
were removed.
使用 QNearFieldTarget::ndefMessageRead () 和 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 注解 URL (统一资源定位符) example shows how to achieve it on Android.
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.
File sharing via NFC is deprecated on Android in API 29. Other technologies should be used instead.
The support for QML API is discontinued.