If your model is C++ based QAbstractListModel is the way to go. You need to override the rowCount and data methods and then use begin/endInsertRows when adding new items. This will inform ListView about those changes and it will then update the appropriate delegates.
http://doc.qt.nokia.com/latest/qabstractlistmodel.html <http://doc.qt.nokia.com/latest/qabstractlistmodel.html> -Pelle On Fri, May 20, 2011 at 12:26 PM, vineeth <[email protected]> wrote: > > I could get this working using : declView->rootContext()-> > setContextProperty(...) to update the model variable used in QML ListBiew, > but I think this involves unnecessary computation. > A more optimal way will be to get a reference to the model of the ListView > and call append on it. > There is a example of this in : > C:\QtSDK\Examples\4.7\declarative\modelviews\listview\dynamiclist\qml\ and I > need to do the same using C++ backend. > Thanks all for the kind reply. > --vineeth > > > > On Fri, May 20, 2011 at 3:18 PM, Pelle Johnsen <[email protected]>wrote: > >> If using ListModel you don't need to reassign the whole model (which is >> bad as it requires ListView to recreate or at least reinitialize all >> delegates). >> >> ListModel has methods for updating the model: append, insert, move, >> remove, clear. I'm guessing it's using the item views mechanism under the >> hood to inform ListView of the changes. >> >> -Pelle >> >> >> On Fri, May 20, 2011 at 11:26 AM, Thomas Ganshorn <[email protected] >> > wrote: >> >>> i read once that you have to reassign the modell to the listview. >>> >>> Not quite good implementation but there seems to be no other solution >>> unless you want to write your own qaim model (wich is something i really >>> hate and would always avoid if possible) >>> >> > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > >
_______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
