View Full Version : QSqlTableModel and QTableView how to set limit?
langziyang
15th October 2010, 03:30
I i am Chinese, so my english is not good :
how can i use QSqlTableModel and QTableView set limit for sqlite? like select * from table limit x,y?
ChrisW67
15th October 2010, 03:58
For read-only model you can use a QSqlQueryModel and a query "select * from mytable order by mycolumn limit 5"
langziyang
15th October 2010, 04:41
For read-only model you can use a QSqlQueryModel and a query "select * from mytable order by mycolumn limit 5"
thanks, i think only this way now? don`t have anly other way??????
ChrisW67
15th October 2010, 05:52
You can write your own read-write model based on the QSqlQueryModel (like QSqlTableModel) but you will have some things to sort out. For example, what happens if the user edits a row and it no longer qualifies for the "top n" query?
You might also be able to use QSortFilterProxyModel on top of a QSqlTableModel (no limit) to present only the first n rows to a view and still be able to edit.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.