QNdefFilter Class

The QNdefFilter class provides a filter for matching NDEF messages. 更多...

头: #include <QNdefFilter>
qmake: QT += nfc
Since: Qt 5.2

该类在 Qt 5.2 引入。

公共函数

QNdefFilter (const QNdefFilter & other )
QNdefFilter ()
QNdefFilter & operator= (const QNdefFilter & other )
~QNdefFilter ()
void appendRecord (unsigned int min = 1, unsigned int max = 1)
void appendRecord (QNdefRecord::TypeNameFormat typeNameFormat , const QByteArray & type , unsigned int min = 1, unsigned int max = 1)
void appendRecord (const QNdefFilter::Record & record )
void clear ()
bool orderMatch () const
QNdefFilter::Record recordAt (int i ) const
int recordCount () const
void setOrderMatch (bool on )

详细描述

The QNdefFilter encapsulates the structure of an NDEF message and is used by QNearFieldManager::registerNdefMessageHandler () to match NDEF message that have a particular structure.

The following filter matches NDEF messages that contain a single smart poster record:

QNdefFilter filter;
filter.append(QNdefRecord::NfcRtd, "Sp");
					

The following filter matches NDEF messages that contain a URI, a localized piece of text and an optional JPEG image. The order of the records must be in the order specified:

QNdefFilter filter;
filter.setOrderMatch(true);
filter.appendRecord(QNdefRecord::NfcRtd, "U");
filter.appendRecord<QNdefNfcTextRecord>();
filter.appendRecord(QNdefRecord::Mime, "image/jpeg", 0, 1);
					

成员函数文档编制

QNdefFilter:: QNdefFilter (const QNdefFilter & other )

constructs a new NDEF filter that is a copy of other .

QNdefFilter:: QNdefFilter ()

Constructs a new NDEF filter.

QNdefFilter &QNdefFilter:: operator= (const QNdefFilter & other )

赋值 other to this filter and returns a reference to this filter.

QNdefFilter:: ~QNdefFilter ()

Destroys the NDEF filter.

template <typename T> void QNdefFilter:: appendRecord ( unsigned int min = 1, unsigned int max = 1)

Appends a record matching the template parameter to the NDEF filter. The record must occur between min and max times in the NDEF message.

void QNdefFilter:: appendRecord ( QNdefRecord::TypeNameFormat typeNameFormat , const QByteArray & type , unsigned int min = 1, unsigned int max = 1)

Appends a record with type name format typeNameFormat and type type to the NDEF filter. The record must occur between min and max times in the NDEF message.

void QNdefFilter:: appendRecord (const QNdefFilter::Record & record )

追加 record to the NDEF filter.

void QNdefFilter:: clear ()

Clears the filter.

bool QNdefFilter:: orderMatch () const

Returns true if the filter takes NDEF record order into account when matching; otherwise returns false.

另请参阅 setOrderMatch ().

QNdefFilter::Record QNdefFilter:: recordAt ( int i ) const

Returns the NDEF record at index i .

int QNdefFilter:: recordCount () const

Returns the number of NDEF records in the filter.

void QNdefFilter:: setOrderMatch ( bool on )

Sets the ording requirements of the filter. If on is true the filter will only match if the order of records in the filter matches the order of the records in the NDEF message. If on is false the order of the records is not taken into account when matching.

By default record order is not taken into account.

另请参阅 orderMatch ().