PySide6.QtNfc.QNearFieldManager¶
- class QNearFieldManager¶
- The - QNearFieldManagerclass provides access to notifications for NFC events. More…- Synopsis¶- Methods¶- def - __init__()
- def - isEnabled()
- def - isSupported()
 - Signals¶
- def - targetDetected()
- def - targetLost()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- NFC Forum devices support two modes of communications. The first mode, peer-to-peer communications, is used to communicate between two NFC Forum devices. The second mode, master/slave communications, is used to communicate between an NFC Forum device and an NFC Forum Tag or Contactless Card. The - targetDetected()signal is emitted when a target device enters communications range. Communications can be initiated from the slot connected to this signal.- NFC Forum devices generally operate as the master in master/slave communications. Some devices are also capable of operating as the slave, so called Card Emulation mode. In this mode the local NFC device emulates a NFC Forum Tag or Contactless Card. - Applications can connect to the - targetDetected()and- targetLost()signals to get notified when an NFC Forum Tag enters or leaves proximity. Before these signals are emitted target detection must be started with the- startTargetDetection()function. Target detection can be stopped with the- stopTargetDetection()function. When the target is no longer required the target should be deleted as other applications may be blocked from accessing the target.- NFC on Linux¶- The Linux NFC project provides software to support NFC on Linux platforms. The neard daemon will allow access to the supported hardware via DBus interfaces. QtNfc requires neard version 0.14 which can be built from source or installed via the appropriate Linux package manager. Not all API features are currently supported. To allow QtNfc to access the DBus interfaces the neard daemon has to be running. In case of problems debug output can be enabled by enabling categorized logging for ‘qt.nfc.neard’. - class AdapterState¶
- This enum describes the different states a NFC adapter can have. - Constant - Description - QNearFieldManager.AdapterState.Offline - The nfc adapter is offline. - QNearFieldManager.AdapterState.TurningOn - The nfc adapter is turning on. - QNearFieldManager.AdapterState.Online - The nfc adapter is online. - QNearFieldManager.AdapterState.TurningOff - The nfc adapter is turning off. 
 - Constructs a new near field manager with - parent.- adapterStateChanged(state)¶
- Parameters:
- state – - AdapterState
 
 - This signal is emitted whenever the - stateof the NFC adapter changed.- Note - Currently, this signal is only emitted on Android. - isEnabled()¶
- Return type:
- bool 
 
 - Returns - trueif the device has a NFC adapter and it is turned on; otherwise returns- false.- See also - isSupported([accessMethod=QNearFieldTarget.AnyAccess])¶
- Parameters:
- accessMethod – - AccessMethod
- Return type:
- bool 
 
 - Returns - trueif the underlying device has a NFC adapter; otherwise returns- false. If an- accessMethodis given, the function returns- trueonly if the NFC adapter supports the given- accessMethod.- See also - setUserInformation(message)¶
- Parameters:
- message – str 
 
 - Sets the message that the system shows to the user. If target detection is running, the - messagewill be updated immediately and can be used as a progress message. The last message set before a call to- startTargetDetection()without an error message is used as a success message. If target detection is not running, the- messagewill be used as the initial message when the next detection is started. By default, no message is shown to the user.- Note - Currently, this function only has an effect on iOS because the system shows a popup during the scan. On iOS, this - messageis mapped to the alert message which is shown upon successful completion of the scan. Other platforms will ignore- message.- startTargetDetection(accessMethod)¶
- Parameters:
- accessMethod – - AccessMethod
- Return type:
- bool 
 
 - Starts detecting targets and returns - trueif target detection started successfully; otherwise returns- false. Causes the- targetDetected()signal to be emitted when a target is within proximity. Only tags with the given- accessMethodwill be reported. Target detection continues until- stopTargetDetection()is called.- To detect targets with a different - accessMethod,- stopTargetDetection()must be called first.- Note - On iOS, it is impossible to start target detection for both NdefAccess and TagTypeSpecificAccess at the same time. So if AnyAccess is selected, NdefAccess will be used instead. - Note - On platforms using neard, target detection will stop as soon as a tag has been detected. - See also - stopTargetDetection([errorMessage=""])¶
- Parameters:
- errorMessage – str 
 
 - Stops detecting targets. The - targetDetected()signal will no longer be emitted until another call to- startTargetDetection()is made. Targets detected before are still valid.- Note - On iOS, detected targets become invalid after this call (e.g. an attempt to write or read NDEF messages will result in an error). - If an - errorMessageis provided, it is a hint to the system that the application’s goal was not achieved. The- errorMessageand a matching error icon are shown to the user. Calling this function with an empty- errorMessageimplies a successful end of operation; otherwise, an- errorMessageshould be passed to this function.- Note - Currently, - errorMessageonly has an effect on iOS because the system shows a popup during the scan where the- errorMessageis visible. Other platforms will ignore this parameter.- See also - targetDetected(target)¶
- Parameters:
- target – - QNearFieldTarget
 
 - This signal is emitted whenever a target is detected. The - targetparameter represents the detected target.- This signal will be emitted for all detected targets. - QNearFieldManagermaintains ownership of- target, however, it will not be destroyed until the- QNearFieldManagerdestructor is called. Ownership may be transferred by calling setParent().- Do not delete - targetfrom the slot connected to this signal, instead call deleteLater().- Note - that if - targetis deleted before it moves out of proximity the- targetLost()signal will not be emitted.- See also - targetDetectionStopped()¶
 - This signal is emitted whenever the target detection is stopped. - Note - Mostly this signal is emitted when - stopTargetDetection()has been called. Additionally the user is able to stop the detection on iOS within a popup shown by the system during the scan, which also leads to emitting this signal.- targetLost(target)¶
- Parameters:
- target – - QNearFieldTarget
 
 - This signal is emitted whenever a target moves out of proximity. The - targetparameter represents the lost target.- Do not delete - targetfrom the slot connected to this signal, instead use deleteLater().- See also