Hi yall,
so I'm trying to do a mulltiple-field sort (i.e. first by surname then by name) and I've chosen to subclass the QSortFilterProxyModel.
I've subclassed it and reimplemented functions
Then my model is derived from a QAbstractListModel (I want to just keep the reference to a list being kept elsewhere)Code:virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
so I reimplemented functions
Then all this content is controlled in a custom list (the purpose is to add i.e. the kinetic scrolling with Flickable)Code://basic function for a read-only model int rowCount ( const QModelIndex & parent = QModelIndex() ) const; QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const ;
and displayed in a custom delegateCode:class MyList : public QListView
In the constructor of the widget that holds that list (it's a central Widget) I do:Code:class MyDelegate : public QItemDelegate
Now the problem is that the list is not sorted, and I've debugged it to see that the function filterAcceptsRow is called but lessThan NOT!Code:m_listview = new MyList(this); m_listview->setStyle(new QWindowsStyle); m_listview->setAutoFillBackground(true); MyModel *model = new MyModel (dataArray, this); MySortProxyModel *proxy = new MySortProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(model); m_listview->setModel(proxy); MyDelegate *delegate = new MyDelegate(this); m_listview->setItemDelegate(delegate);
I've tried to read the Qt source, but not much luck there as I get lost when some signal is fired.
Please help, I wonder where I missed some decoration to make it work properly...

Reply With Quote


