PDA

View Full Version : Apply a row limit on a model or a view



remy_david
25th February 2011, 18:03
Hi all,

I would like to limit the number of row displayed by my view (let say I want to display the first 20 rows). I am using a subclass of QSqlTableModel for my model and a subclass of QListView for my view. I don't mind if the limitation is done by the view or by the model (although better if done in the model).

How can I achieve that ?

I though about editing the select statement of my model with a LIMIT clause, but it doesn't seems to be possible. Also setFilter does not make the trick cause it affect only the WHERE part.

Thanks

wysota
25th February 2011, 18:44
Use a subclass of QSortFilterProxyModel.