examples/declarative/cppextensions/plugins/plugin.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    94 private:
    94 private:
    95     QTime time;
    95     QTime time;
    96     QBasicTimer timer;
    96     QBasicTimer timer;
    97 };
    97 };
    98 
    98 
       
    99 //![0]
    99 class TimeModel : public QObject
   100 class TimeModel : public QObject
   100 {
   101 {
   101     Q_OBJECT
   102     Q_OBJECT
   102     Q_PROPERTY(int hour READ hour NOTIFY timeChanged)
   103     Q_PROPERTY(int hour READ hour NOTIFY timeChanged)
   103     Q_PROPERTY(int minute READ minute NOTIFY timeChanged)
   104     Q_PROPERTY(int minute READ minute NOTIFY timeChanged)
       
   105 //![0]
   104 
   106 
   105 public:
   107 public:
   106     TimeModel(QObject *parent=0) : QObject(parent)
   108     TimeModel(QObject *parent=0) : QObject(parent)
   107     {
   109     {
   108         if (++instances == 1) {
   110         if (++instances == 1) {
   133 };
   135 };
   134 
   136 
   135 int TimeModel::instances=0;
   137 int TimeModel::instances=0;
   136 MinuteTimer *TimeModel::timer=0;
   138 MinuteTimer *TimeModel::timer=0;
   137 
   139 
       
   140 //![plugin]
   138 class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
   141 class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
   139 {
   142 {
   140     Q_OBJECT
   143     Q_OBJECT
   141 public:
   144 public:
   142     void registerTypes(const char *uri)
   145     void registerTypes(const char *uri)
   143     {
   146     {
   144         Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample"));
   147         Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample"));
   145         qmlRegisterType<TimeModel>(uri, 1, 0, "Time");
   148         qmlRegisterType<TimeModel>(uri, 1, 0, "Time");
   146     }
   149     }
   147 };
   150 };
       
   151 //![plugin]
   148 
   152 
   149 #include "plugin.moc"
   153 #include "plugin.moc"
   150 
   154 
   151 Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin);
   155 //![export]
       
   156 Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin);
       
   157 //![export]