Results 1 to 4 of 4

Thread: Custom Model Advice Requested

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    35
    Thanked 1 Time in 1 Post

    Default Re: Custom Model Advice Requested

    Thanks caduel, it does seem like a simple solution. And, it solves my problem of showing common data in the 'Base' table by using different views for each device type.

    The only drawback for me is I now need to understand the QSortFilterProxyModel .

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: Custom Model Advice Requested

    That is not really hard.
    (Except that you now have two models with their own indexes. Thus you have now the possibility to use an index of model A with model B which would be not good at all. Just remember that an index you get (usually from a view's signals) is an index of that view's model. If you use a proxy, it is therefore an index of the proxy model. You have to map the index back to the source model with QSortFilterProxyModel::mapToSource() or, if possible, avoid the danger by writing

    Qt Code:
    1. // tv being a QTreeView* and idx an index 'signaled' by it
    2. tv->model()->data(idx);
    3. idx.data()
    4.  
    5. // rather than
    6. myModel.data(idx); // with myModel being your (proxy's source) model
    7. // This second approach is unhappy if you introduce proxies (you could layer those...) later on.
    To copy to clipboard, switch view to plain text mode 
    )

    Hope this gets you going.

Similar Threads

  1. Model / Threading Advice
    By tntcoda in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2008, 14:02
  2. Custom proxy model issue
    By Khal Drogo in forum Qt Programming
    Replies: 13
    Last Post: 30th November 2007, 12:41
  3. Custom Model Help PLz
    By Simz in forum Qt Programming
    Replies: 3
    Last Post: 16th August 2007, 15:28
  4. Help with getting my custom model working
    By thomaspu in forum Qt Programming
    Replies: 19
    Last Post: 29th July 2007, 18:35
  5. Treeview and custom model
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 15th May 2007, 13:54

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.