Qt-interest Archive, September 2007
Inserting data into Model when linked to Proxy
Message 1 in thread
Hello,
I have 3 classes (changed names here for convenience):
- MyListView (QListView subclass)
- MyListModel (QAbstractListModel subclass)
- MyListProxy (QSortFilterProxyModel subclass)
Each of these classes have basic functionality, for now. I wanted to add
custom sorting to MyListView, in case you were wondering why I need
MyListProxy.
In my application MyListModel always starts out with empty data, but
data gets inserted/removed during runtime, and when using MyListView
connected only to MyListModel, everything works fine.
When I want to use MyListProxy however, the new rows are NOT updated
into the view. If however I start my application with a non-empty
MyListModel, the view will show these rows, so it is only insertRow()
functionality that is not working...
I call MyListModel::insertRow(), which contains the beginInsertRows()
and endInsertRows() calls.
I thought this was sufficient to let all other components know data has
been inserted? So now I am confused. Do I need to make an
MyListProxy::insertRow() function which then calls
MyListModel::insertRow() ??? And should it do anything more ? :) I'd
like to know what needs to be done, and especially why.
Forgive my ignorance, but the docs have little information to offer when
it comes to inserting/removing rows when using a proxy model.
Regards,
Stefan Vunckx
--
[ signature omitted ]