QtMobility Reference Documentation

Contents

QDeclarativeNdefRecord Class Reference

The QDeclarativeNdefRecord class implements the NdefRecord element in QML. More...

 #include <QDeclarativeNdefRecord>

Inherits: QObject.

Properties

Public Functions

QDeclarativeNdefRecord ( QObject * parent = 0 )
QDeclarativeNdefRecord ( const QNdefRecord & record, QObject * parent = 0 )
QNdefRecord record () const
QString recordType () const
void setRecord ( const QNdefRecord & record )
void setRecordType ( const QString & type )

Signals

void recordTypeChanged ()

Macros

Q_DECLARE_NDEFRECORD ( className, typeNameFormat, type )

Additional Inherited Members

Detailed Description

The QDeclarativeNdefRecord class implements the NdefRecord element in QML.

The QDeclarativeNdefRecord class is the base class for all NdefRecord elements 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:

For example the declaration of such a class may look like the following.

 class QDeclarativeNdefFooRecord : public QDeclarativeNdefRecord
 {
     Q_OBJECT

     Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged)

 public:
     explicit QDeclarativeNdefFooRecord(QObject *parent = 0);
     Q_INVOKABLE QDeclarativeNdefFooRecord(const QNdefRecord &record, QObject *parent = 0);
     ~QDeclarativeNdefFooRecord();

     int foo() const;
     void setFoo(int value);

 signals:
     void fooChanged();
 };

Within the implementation file the Q_DECLARE_NDEFRECORD() macro is expanded:

 Q_DECLARE_NDEFRECORD(QDeclarativeNdefFooRecord, QNdefRecord::ExternalRtd, "com.example:f")

Finially the application or plugin code calls qmlRegisterType():

 qmlRegisterType<QDeclarativeNdefFooRecord>(uri, 1, 0, "NdefFooRecord");

See also NdefRecord.

Property Documentation

recordType : QString

This property hold the record type of the NDEF record that this class represents.

Access functions:

QString recordType () const
void setRecordType ( const QString & type )

Notifier signal:

void recordTypeChanged ()

Member Function Documentation

QDeclarativeNdefRecord::QDeclarativeNdefRecord ( QObject * parent = 0 )

Constructs a new empty QDeclarativeNdefRecord with parent.

QDeclarativeNdefRecord::QDeclarativeNdefRecord ( const QNdefRecord & record, QObject * parent = 0 )

Constructs a new QDeclarativeNdefRecord representing record. The parent of the newly constructed object will be set to parent.

QNdefRecord QDeclarativeNdefRecord::record () const

Returns a copy of the record.

See also setRecord().

void QDeclarativeNdefRecord::recordTypeChanged () [signal]

This signal is emitted when the record type changes.

void QDeclarativeNdefRecord::setRecord ( const QNdefRecord & record )

Sets the record to record.

See also record().

Macro Documentation

Q_DECLARE_NDEFRECORD ( className, typeNameFormat, type )

This macro ensures that className is declared as the class implementing the NDEF record identified by typeNameFormat and type.

This macro should be expanded in the implementation file for className.