The current QAbastractModel setup requires you to have an actual class
that represents your data. I'm looking for something more flexible. It
is obvious from the capability to create ListModel components and
populate them with ListElement(s) from a static QML documents, that QT
is able to create and populate a listmodel with dynamic roles.

The snippet below finds a QDeclarativeListModel QML component, but the
interface is private.  This snippet below should give an idea as to
  what i want to do.

--------- qml object
ListModel {
          id: dataBank
  objectName: "dataBank"

     ListElement {
          value: "value1 query"
          value2: "value2 query"
          value3: "value3 query"
      }
}
--------

-------- cpp
QList<QObject *> model = viewRoot->findChildren<QObject*>("dataBank");

if (model.size() > 0) {
    for(int i = 0; i < model.size(); ++i) {
       QDeclarativeListModel *item = qobject_cast<QDeclarativeListModel 
*>(model[i]);
       // read values from listelement for value, value2 and value3
       // process queries for  value, value2 and value3
       // update listelement 0 with -> valueObj, value2Obj, value3Obj
       // insert listelement 1 with -> valueObj, value2Obj, value3Obj
       // insert listelement 2 with -> valueObj, value2Obj, value3Obj
       // insert listelement 3 with -> valueObj, value2Obj, value3Obj
     }
}
else
{
     qDebug() << "no model found";
}

// update values on valueObj, value2Obj, value3Obj in another thread and 
have view updated.

------- cpp

Any ideas/pointers?


-- 
Tim O'Callaghan
Research &  Development
MEYN - Food Processing Technology B.V.
Noordeinde 68 - 1511 AE Oostzaan - The Netherlands
Phone: +31 756 84 3355 | Fax: +31 756 84 4150| E-mail: 
[email protected]  | Web: http://www.meyn.nl
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to