Код: Выделить всё
proxy = new MyFilterModel();
proxy->setSourceModel(...);
proxy->setDynamicSortFilter(true);
proxy->setFilterParams(...); // my custom function
comboBox->setModel(proxy);
В конце концов я переопределил setSourceModel в MyFilterModel вот так:
Код: Выделить всё
void MyFilterModel::setSourceModel(QAbstractItemModel *sourceModel)
{
QSortFilterProxyModel::setSourceModel(sourceModel);
connect(sourceModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(doInvalidateFilter()));
connect(sourceModel, SIGNAL(modelReset()), this, SLOT(doInvalidateFilter()));
invalidateFilter();
}
Однако я полагаю, что setDynamicSortFilter уже должен был позаботиться об этом. Это ошибка в Qt?
Подробнее здесь: https://stackoverflow.com/questions/321 ... ate-filter
Мобильная версия