Results 1 to 3 of 3

Thread: General Question about Qt4 Model/View

  1. #1
    Join Date
    May 2008
    Posts
    9
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default General Question about Qt4 Model/View

    Hello, I'm new. I've done a little Qt programming (Qt 3) but am now starting a program in which I want to more extensively use Qt 4 features, including the abstract model/view stuff.

    My general question is this: are the items in a model assumed to have an order (be an order ed list, rather than an unordered set) -- since they are indexed by an integer this seems to be the case. And are integers always used, or could they have some other key like a string or variable size hash value? And if you sort items in a view, that pertains only to that view's display, not to the ordering in the model?

    Thanks

    Reed

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

    Default Re: General Question about Qt4 Model/View

    Quote Originally Posted by reed View Post
    My general question is this: are the items in a model assumed to have an order
    A logical order (you have to be able to identify each of the items). You can present them in any way you want using a custom view.

    And are integers always used, or could they have some other key like a string or variable size hash value?
    You can order strings or hash values, so you can map it to integers easily. You just have to know which of two keys is earlier in the set and which is later.

    And if you sort items in a view, that pertains only to that view's display, not to the ordering in the model?
    It changes the order of items in the model (QAbstractItemModel::sort() is called). If you want to keep the order of the items, wrap your model into QSortFilterProxyModel and set that as the view's model.

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

    reed (2nd September 2008)

  4. #3
    Join Date
    May 2008
    Posts
    9
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: General Question about Qt4 Model/View

    Thanks. I want the order to stay in the view, not change the model (since the model is fundamentally unordered). So the sort proxy sounds like what I want. (A sort proxy for each view.)
    Last edited by reed; 13th May 2008 at 15:15.

Similar Threads

  1. quick question on model/view programming
    By locus in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2007, 10:04

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.