Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
How to display partial data from a QSqlQueryModel in a QTableView?
I have a sql query that retrieves 100 records and I want to display 10 of those records at a time and provide "Next", "Previous" buttons to move across pags of records. Any pointers on how to achieve this?
How to display partial data from a QSqlQueryModel in a QTableView?
hmm..
Limit your query to 10 first
when the next button click get 10 again but this time starting from the last number your tableview holding in this case 10+1
like: select * from table limit 11,10; //11 is where your query starts and 10 is the limit
if previous click subtract 10 to your last number.. and so on.. hope that help
Updating the query for the next/previous pages by setting the limit and the offset indeed works.
However, I am trying to achieve some performance enhancement by not querying the database for every page. Instead, If I have 100 records on hand in the Model, I would like to display 10 at a time in the view. Not sure if this is achievable.
Updating the query for the next/previous pages by setting the limit and the offset indeed works.
However, I am trying to achieve some performance enhancement by not querying the database for every page. Instead, If I have 100 records on hand in the Model, I would like to display 10 at a time in the view. Not sure if this is achievable.
The simplest way would be to create a data structure representing the SQL Record coming back and then represent it as a vector or a dynamic array(you'd need to write this one) then just put the data you want to display into a Custom Model and present any way you like.
---
Regards,
Mikhail
look at QSortFilterProxyModel
Nicolas