QtMobility Reference Documentation

QDeclarativeNdefRecord Class Reference

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

 #include <QDeclarativeNdefRecord>

Inherits: QObject.

Properties

  • 1 property inherited from QObject

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 )
  • 29 public functions inherited from QObject

Signals

void recordTypeChanged ()

Macros

Q_DECLARE_NDEFRECORD ( className, typeNameFormat, type )

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

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:

  • 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 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.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.