QQmlNdefRecord Class
The QQmlNdefRecord class implements the NdefRecord type in QML. 更多...
头文件: | #include <QQmlNdefRecord> |
qmake: | QT += nfc |
开始支持版本: | Qt 5.2 |
Instantiated By: | NdefRecord |
基类: | QObject |
公有类型
enum | TypeNameFormat { Empty, NfcRtd, Mime, Uri, ExternalRtd, Unknown } |
属性
- record : QNdefRecord
- type : QString
- typeNameFormat : TypeNameFormat
- 1 个属性继承自 QObject
公有函数
QQmlNdefRecord(QObject *parent = Q_NULLPTR) | |
QQmlNdefRecord(const QNdefRecord &record, QObject *parent = Q_NULLPTR) | |
~QQmlNdefRecord() | |
QNdefRecord | record() const |
void | setRecord(const QNdefRecord &record) |
void | setType(const QString &newtype) |
void | setTypeNameFormat(TypeNameFormat newTypeNameFormat) |
QString | type() const |
TypeNameFormat | typeNameFormat() const |
- 32 个公有函数继承自 QObject
信号
void | recordChanged() |
void | typeChanged() |
void | typeNameFormatChanged() |
- 2 个信号继承自 QObject
Macros
Q_DECLARE_NDEFRECORD(className, typeNameFormat, type) |
其他继承的成员
- 1 个公有槽函数继承自 QObject
- 1 个公有变量继承自 QObject
- 10 个静态公有成员继承自 QObject
- 9 个受保护的函数继承自 QObject
- 2 个受保护的变量继承自 QObject
详细描述
The QQmlNdefRecord class implements the NdefRecord type in QML.
The QQmlNdefRecord class is the base class for all NdefRecord types in QML. To support a new NDEF record type in QML subclass this class and expose new properties, member functions and signals appropriate for the new record type. The following must be done to create a new NDEF record type in QML:
- The subclass must have a Q_OBJECT macro in its declaration.
- The subclass must have an invokable constructor that takes a QNdefRecord and a QObject pointer.
- The subclass must be declared as an NDEF record by expanding the Q_DECLARE_NDEFRECORD() macro in the implementation file of the subclass.
- The subclass must be registered with QML.
For example the declaration of such a class may look like the following.
class QQmlNdefFooRecord : public QQmlNdefRecord { Q_OBJECT Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged) public: explicit QQmlNdefFooRecord(QObject *parent = 0); Q_INVOKABLE QQmlNdefFooRecord(const QNdefRecord &record, QObject *parent = 0); ~QQmlNdefFooRecord(); int foo() const; void setFoo(int value); signals: void fooChanged(); };
Within the implementation file the Q_DECLARE_NDEFRECORD() macro is expanded:
Q_DECLARE_NDEFRECORD(QQmlNdefFooRecord, QNdefRecord::ExternalRtd, "com.example:f")
Finially the application or plugin code calls qmlRegisterType():
qmlRegisterType<QQmlNdefFooRecord>(uri, 1, 0, "NdefFooRecord");
参见 NdefRecord.
成员类型
enum QQmlNdefRecord::TypeNameFormat
This enum describes the type name format of an NDEF record. The values of this enum are according to QNdefRecord::TypeNameFormat
Constant | Value | Description |
---|---|---|
QQmlNdefRecord::Empty | QNdefRecord::Empty | An empty NDEF record, the record does not contain a payload. |
QQmlNdefRecord::NfcRtd | QNdefRecord::NfcRtd | The NDEF record type is defined by an NFC RTD Specification. |
QQmlNdefRecord::Mime | QNdefRecord::Mime | The NDEF record type follows the construct described in RFC 2046. |
QQmlNdefRecord::Uri | QNdefRecord::Uri | The NDEF record type follows the construct described in RFC 3986. |
QQmlNdefRecord::ExternalRtd | QNdefRecord::ExternalRtd | The NDEF record type follows the construct for external type names described the NFC RTD Specification. |
QQmlNdefRecord::Unknown | QNdefRecord::Unknown | The NDEF record type is unknown. |
属性
record : QNdefRecord
This property hold the NDEF record that this class represents.
访问函数:
Notifier signal:
void | recordChanged() |
type : QString
This property hold the type of the NDEF record.
访问函数:
Notifier signal:
void | typeChanged() |
typeNameFormat : TypeNameFormat
This property hold the TNF of the NDEF record.
访问函数:
TypeNameFormat | typeNameFormat() const |
void | setTypeNameFormat(TypeNameFormat newTypeNameFormat) |
Notifier signal:
void | typeNameFormatChanged() |
成员函数
QQmlNdefRecord::QQmlNdefRecord(QObject *parent = Q_NULLPTR)
Constructs a new empty QQmlNdefRecord with parent.
QQmlNdefRecord::QQmlNdefRecord(const QNdefRecord &record, QObject *parent = Q_NULLPTR)
Constructs a new QQmlNdefRecord representing record. The parent of the newly constructed object will be set to parent.
QQmlNdefRecord::~QQmlNdefRecord()
Destroys the QQmlNdefRecord instance.
QNdefRecord QQmlNdefRecord::record() const
Returns a copy of the record.
Note: Getter function for property record.
参见 setRecord().
void QQmlNdefRecord::setRecord(const QNdefRecord &record)
Sets the record to record. If the record is set the recordChanged() signal will be emitted.
Note: Setter function for property record.
参见 record().
void QQmlNdefRecord::setType(const QString &newtype)
Sets the record type to newtype if it is not currently equal to type(); otherwise does nothing. If the record type is set the typeChanged() signal will be emitted.
Note: Setter function for property type.
参见 QNdefRecord::setType() and QNdefRecord::type().
void QQmlNdefRecord::setTypeNameFormat(TypeNameFormat newTypeNameFormat)
Sets the type name format of the NDEF record to newTypeNameFormat.
Note: Setter function for property typeNameFormat.
参见 typeNameFormat().
QString QQmlNdefRecord::type() const
Returns the type of the record.
Note: Getter function for property type.
参见 QNdefRecord::setType() and QNdefRecord::type().
[signal]
void QQmlNdefRecord::typeChanged()
This signal is emitted when the record type changes.
Note: Notifier signal for property type.
TypeNameFormat QQmlNdefRecord::typeNameFormat() const
Returns the type name format of the NDEF record.
Note: Getter function for property typeNameFormat.
参见 setTypeNameFormat().