diff --git a/declarativeimports/core/datamodel.cpp b/declarativeimports/core/datamodel.cpp index 796366d67..e3610da86 100644 --- a/declarativeimports/core/datamodel.cpp +++ b/declarativeimports/core/datamodel.cpp @@ -74,12 +74,15 @@ void SortFilterModel::setModel(QAbstractItemModel* model) if (sourceModel()) { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(syncRoleNames())); } + + QSortFilterProxyModel::setSourceModel(model); + if (model) { connect(model, SIGNAL(modelReset()), this, SLOT(syncRoleNames())); + syncRoleNames(); } - QSortFilterProxyModel::setSourceModel(model); - syncRoleNames(); - sourceModelChanged(model); + + emit sourceModelChanged(model); }