Results 1 to 2 of 2

Thread: Model/View Confusion in QTreeView - number of rows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Location
    New York
    Posts
    45
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Model/View Confusion in QTreeView - number of rows

    I am trying to create a model/view system for plugins. Each plugin has different attributes, which should be displayed in a QTreeView.

    I am confused, however, if the view's number of rows does not match the number of items in the model.

    For instance, I want to display the plugins like this:
    Qt Code:
    1. (root)
    2. +-Transform Nodes 2 nodes
    3. | +-Move
    4. | | +-Inputs
    5. | | | input1 image
    6. | | +-Attributes 2 attributes
    7. | | Xpos float
    8. | | Ypos float
    9. | +-Rotate
    10. | +-Inputs
    11. | | input1 image
    12. | +-Attributes 1 attribute
    13. | angle float
    14. +-Color Nodes 2 nodes
    15. +-Brightness
    16. | +-Inputs
    17. | | input1 image
    18. | +-Attributes 1 attribute
    19. | amount float
    20. +-etc... etc...
    To copy to clipboard, switch view to plain text mode 

    which leads me to believe that I have 2 groups, and 2 children in each group (potentially many of each, but for this example...), and certain rows have two columns, but others only have one. The inputs and attributes are not child items, they only exist in the view and are really members of pluginItem.

    The problem is, while the model has 2 groups of 2 items, the view has 19 (and more) rows. Also, another problem is that the row number of a particular item is determined by which parents are expanded/collapsed (but this may already be contained in the QTreeView code).

    Does it make more sense to:

    1) create a pluginGroup class which contains pluginItem children that reports many rows when displayed, or
    2) create a pluginGroup class which contains pluginItem children that contains pluginDisplayGroup children that contains pluginDisplayAttribute children, or
    3) create a generic pluginRow item which may be either a child or parent and has a flag in it to determine usage, or
    4) create a pluginItem array in the model, which stores the group name, where the view somehow splits the rows based on unique group names, or
    5) some other framework that I'm not thinking of.

    Another, more minor thing, is that if I want the view to expand/collapse based on a single click... where do I insert this trigger? Do I need a delegate?

    I would like to use 4 or 1 above, but I am confused about where the additonal rows are generated... 4 makes the most sense, because that's what the model really should be.
    Last edited by themolecule; 6th August 2007 at 01:10.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Replies: 6
    Last Post: 5th March 2006, 21:05

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.