PySide6.QtNfc.QNdefRecord¶
- class QNdefRecord¶
The
QNdefRecord
class provides an NFC NDEF record. More…Inherited by:
QNdefNfcUriRecord
,QNdefNfcTextRecord
,QNdefNfcIconRecord
,QNdefNfcSmartPosterRecord
Synopsis¶
Methods¶
def
__init__()
def
clear()
def
id()
def
isEmpty()
def
__ne__()
def
__eq__()
def
payload()
def
setId()
def
setPayload()
def
setType()
def
type()
def
typeNameFormat()
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¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
QNdefRecord
and derived classes are used to parse the contents ofNDEF messages
and create new NDEF messages.Use
typeNameFormat()
andsetTypeNameFormat()
to get and set the type name format of the NDEF record.Use
type()
andsetType()
to get and set the type of the NDEF record.Use
id()
andsetId()
to get and set the id of the NDEF record.Use
payload()
andsetPayload()
to get and set the NDEF record payload.isEmpty()
can be used to test if the payload is empty.QNdefRecord
is an implicitly shared class. This means you can efficiently convert betweenQNdefRecord
and specialized record classes. TheisRecordType()
template function can be used to test if a conversion is possible. The following example shows how to test if aQNdefRecord
is an NFC RTD Text record and extract the text information from it.if record.isRecordType<QNdefNfcTextRecord>(): textRecord = QNdefNfcTextRecord(record) print(textRecord.text())
Creating Specialized NDEF Record Classes¶
Specialized NDEF record classes can be easily created with the
Q_DECLARE_NDEF_RECORD()
andQ_DECLARE_ISRECORDTYPE_FOR_NDEF_RECORD()
macros. The following example shows the class declaration of the hypothetical example.com:f record type that encapsulates a single int property foo.class ExampleComF(QNdefRecord): # public Q_DECLARE_NDEF_RECORD(ExampleComF, QNdefRecord.ExternalRtd, "example.com:f", QByteArray(sizeof(int), char(0))) foo = int() def setFoo(v): Q_DECLARE_ISRECORDTYPE_FOR_NDEF_RECORD(ExampleComF, QNdefRecord.ExternalRtd, "example.com:f")
The developer only needs to provide implementations for the
foo()
andsetFoo()
functions that parse and set the contents of the NDEF record’s payload.- class TypeNameFormat¶
This enum describes the type name format of an NDEF record.
Constant
Description
QNdefRecord.Empty
An empty NDEF record, the record does not contain a payload
QNdefRecord.NfcRtd
The NDEF record type is defined by an NFC RTD Specification
QNdefRecord.Mime
The NDEF record type follows the construct described in RFC 2046
QNdefRecord.Uri
The NDEF record type follows the construct described in RFC 3986
QNdefRecord.ExternalRtd
The NDEF record type follows the construct for external type names described the NFC RTD Specification
QNdefRecord.Unknown
The type of the record is unknown and should be treated similar to content with MIME type ‘application/octet-stream’ without further context
- __init__()¶
Constructs a new empty NDEF record.
- __init__(other)
- Parameters:
other –
QNdefRecord
Constructs a new NDEF record that is a copy of
other
.- __init__(typeNameFormat, type)
- Parameters:
typeNameFormat –
TypeNameFormat
type –
QByteArray
- __init__(other, typeNameFormat)
- Parameters:
other –
QNdefRecord
typeNameFormat –
TypeNameFormat
- __init__(other, typeNameFormat, type)
- Parameters:
other –
QNdefRecord
typeNameFormat –
TypeNameFormat
type –
QByteArray
- clear()¶
Clear the NDEF record.
An
isEmpty()
call returnstrue
for a cleared record. The recordtype()
is set toEmpty
.- id()¶
- Return type:
Returns the id of the NDEF record.
See also
- isEmpty()¶
- Return type:
bool
Returns
true
if the NDEF record contains an empty payload; otherwise returnsfalse
.This is equivalent to calling
payload().isEmpty()
.- __ne__(other)¶
- Parameters:
other –
QNdefRecord
- Return type:
bool
Returns
true
if this NDEF record does not equalother
; otherwise returnfalse
.- __eq__(other)¶
- Parameters:
other –
QNdefRecord
- Return type:
bool
Returns
true
ifother
and this NDEF record are the same. Otherwise returnsfalse
.- payload()¶
- Return type:
Returns the payload of the NDEF record.
See also
- setId(id)¶
- Parameters:
id –
QByteArray
Sets the id of the NDEF record to
id
.See also
- setPayload(payload)¶
- Parameters:
payload –
QByteArray
Sets the payload of the NDEF record to
payload
.See also
- setType(type)¶
- Parameters:
type –
QByteArray
Sets the type of the NDEF record to
type
.See also
- setTypeNameFormat(typeNameFormat)¶
- Parameters:
typeNameFormat –
TypeNameFormat
Sets the type name format of the NDEF record to
typeNameFormat
.See also
- type()¶
- Return type:
Returns the type of the NDEF record.
See also
- typeNameFormat()¶
- Return type:
Returns the type name format of the NDEF record.
See also