Results 1 to 9 of 9

Thread: Model / View - Design Question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Model / View - Design Question

    Hi !

    I have a tree "domain model" with a lot of different nodes.
    Access to the domain model is done through QAbstractItemModel which acts more like an adapter to the domain model.
    The views (tree view and table view - like an explorer) are attached through two proxy models to the adapter.
    The problem is that the table view shows a lot of different data (but partially the same as the tree view) and this depends on the selected node. Unfortunately setRootIndex() which is used to select what has to be shown in the table view doesn't provide something to adjust the header of the table view (the header/data should come from the item set by setRootIndex() and not the model itself).
    Providing all possible headers and filtering through a proxy (depending on the node type) is complicated for such a lot of different data/headers.
    Using different Q...Models (one always attached for the tree and one dynamically attached to the selected node) attached to the domain model would imply that I have to do the synchronisation by my self (That's not what I want, when Qt provides this already)

    It looks like a sub-model (table) within the model (tree).
    So what's the best solution for that problem ?

    Example:

    tree view
    ----------
    node1
    ...+--- node11
    ...+--- node12
    .............+--- node 121
    ....

    table view node1 selected:
    =================
    name | h1 | h2 | h3 | h4
    -------------------------------
    node11 | x1 | x2 | x3 | x4
    node12 | y1 | y2 | y3 | y4

    table view node 121 selected:
    ==================
    name | h1 | h7
    --------------------------------
    node121 | a1 | a7

    .... (lets assume 30 different nodes types, and a lot of different columns)

    many thanks for your help,
    bernd

    Note: mixing up the tree content with the table content looks like a little bit of violation of "separation of concernce" to me. nevertheless - it's legacy code and can't be changed.
    Last edited by antarctic; 4th June 2009 at 23:48. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 18th November 2009, 23:21
  2. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  3. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 08:50
  4. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 13:01
  5. Replies: 6
    Last Post: 20th April 2006, 10:23

Tags for this Thread

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.