Results 1 to 2 of 2

Thread: Apply a row limit on a model or a view

  1. #1
    Join Date
    Dec 2010
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Question Apply a row limit on a model or a view

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Apply a row limit on a model or a view

    Use a subclass of QSortFilterProxyModel.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 24th February 2011, 05:54
  2. Model/view, apply a filter on model
    By remy_david in forum Qt Programming
    Replies: 4
    Last Post: 4th February 2011, 17:13
  3. Replies: 0
    Last Post: 21st April 2010, 12:23
  4. Replies: 1
    Last Post: 1st February 2010, 18:42
  5. QSql Model-View: How to keep view in sync with model
    By schall_l in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2008, 23:31

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
  •  
Qt is a trademark of The Qt Company.