Results 1 to 4 of 4

Thread: QSqlTableModel and QTableView how to set limit?

  1. #1
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSqlTableModel and QTableView how to set limit?

    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?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlTableModel and QTableView how to set limit?

    For read-only model you can use a QSqlQueryModel and a query "select * from mytable order by mycolumn limit 5"

  3. The following user says thank you to ChrisW67 for this useful post:

    langziyang (15th October 2010)

  4. #3
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlTableModel and QTableView how to set limit?

    Quote Originally Posted by ChrisW67 View Post
    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??????

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlTableModel and QTableView how to set limit?

    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.

Similar Threads

  1. Replies: 2
    Last Post: 2nd March 2010, 04:24
  2. Deleting QSqlTableModel and QTableView
    By waynew in forum Qt Programming
    Replies: 7
    Last Post: 24th December 2009, 00:17
  3. QSqlTableModel and QTableView critics.
    By Avrohom in forum Qt Programming
    Replies: 5
    Last Post: 11th September 2009, 03:17
  4. Replies: 2
    Last Post: 6th January 2009, 20:55
  5. QTableView and QSQLTableModel
    By raphaelf in forum Qt Programming
    Replies: 6
    Last Post: 4th March 2006, 18:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.