I wish to see how QQmlListProperty is used. I tried the following but I am not sure if this is the correct way to do it. I got an error shown in the title.

aa.h
Qt Code:
  1. #ifndef IMO
  2. #define IMO
  3.  
  4. #include <QQmlListProperty>
  5. #include "DummyClass.h"
  6.  
  7. class SubClass: public QObject
  8. {
  9. Q_OBJECT
  10.  
  11. Q_PROPERTY (QQmlListProperty <DummyClass> functionWhat READ functionWhat)
  12.  
  13. public:
  14. SubClass (QObject *parent = 0);
  15. QQmlListProperty <DummyClass> functionWhat()
  16. {
  17. return QQmlListProperty <DummyClass> (this, dummyList);
  18. }
  19.  
  20. private:
  21. QList <DummyClass*> dummyList;
  22. };
  23.  
  24. #endif
To copy to clipboard, switch view to plain text mode 

aa.cpp
Qt Code:
  1. #include "aa.h"
  2.  
  3. #include <QtGui/QGuiApplication>
  4. #include "qtquick2applicationviewer.h"
  5.  
  6. SubClass :: SubClass (QObject *parent) : QObject (parent)
  7. {
  8. qDebug ("In Constructor.");
  9. }
  10.  
  11. void appendDummies (QQmlListProperty<DummyClass> *property, DummyClass *dc)
  12. {
  13. qDebug ("Do nothing. Can't add to a directory using this method.");
  14. }
To copy to clipboard, switch view to plain text mode 

DummyClass.h
Qt Code:
  1. #ifndef IM
  2. #define IM
  3. #include <QObject>
  4.  
  5. class DummyClass : public QObject
  6. {
  7. private:
  8. Q_OBJECT
  9. Q_PROPERTY (bool functionWhat READ functionWhat WRITE functionSetWhat)
  10. public:
  11. DummyClass (QObject *parent = 0) {}
  12.  
  13. float lat; float lon;
  14.  
  15. bool functionWhat ()
  16. {
  17. qDebug ("In functionWhat");
  18. }
  19.  
  20. public slots:
  21. void functionSetWhat (bool arg)
  22. {
  23. qDebug ("In functionWhatSlot");
  24. }
  25.  
  26. signals:
  27. void functionWhatChanged (bool arg);
  28. };
  29.  
  30. #endif
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QtGui/QGuiApplication>
  2. #include "qtquick2applicationviewer.h"
  3. #include "/home/anisha/qmllistproperties/DummyClass.h"
  4. #include <QtQml>
  5. #include "/home/anisha/qmllistproperties/aa.h"
  6. int main(int argc, char *argv[])
  7. {
  8. QGuiApplication app(argc, argv);
  9.  
  10. const char* ocuui = "OCUUI"; // @uri OCUUI
  11.  
  12. qmlRegisterType <DummyClass> (ocuui, 1, 0, "DummyClass");
  13. qmlRegisterType <SubClass> (ocuui, 1, 0, "SubClass");
  14.  
  15.  
  16. QtQuick2ApplicationViewer viewer;
  17. viewer.setMainQmlFile(QStringLiteral("qml/untitled/main.qml"));
  18. viewer.showExpanded();
  19.  
  20. return app.exec();
  21. }
To copy to clipboard, switch view to plain text mode 

main.qml
Qt Code:
  1. import QtQuick 2.0
  2. import OCUUI 1.0
  3.  
  4. Rectangle {
  5. width: 360
  6. height: 360
  7. Text {
  8. text: qsTr("Hello World")
  9. anchors.centerIn: parent
  10. }
  11.  
  12. SubClass
  13. {
  14. functionWhat:
  15. [
  16. DummyClass
  17. {
  18. lat: "2"
  19. lon: "3"
  20. }
  21. ]
  22. }
  23.  
  24.  
  25. MouseArea {
  26. anchors.fill: parent
  27. onClicked: {
  28. Qt.quit();
  29. }
  30. }
  31. }
To copy to clipboard, switch view to plain text mode