Results 1 to 9 of 9

Thread: QTreeView: hide parents but show children?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2015
    Location
    Vermont
    Posts
    48
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QTreeView: hide parents but show children?

    I am trying to figure out if it is possible to hide certain parents in a QTreeView (or TreeWidget, possibly) without hiding the children. For example:

    Qt Code:
    1. Cars
    2. |_Toyota
    3. | |_Camry
    4. | |_Corolla
    5. |
    6. |_Nissan
    7. |_Altima
    8. |_Pathfinder
    9. |_Versa
    To copy to clipboard, switch view to plain text mode 

    Is it possible to hide items in such a way that all that is show is:

    Qt Code:
    1. Camry
    2. Corolla
    3. Altima
    4. Pathfinder
    5. Versa
    To copy to clipboard, switch view to plain text mode 

    This is a simplified example to illustrate. Effectively the functionality that I'm trying to achieve is as follows:
    A "parent" item represents a class of object, and all of it's child objects share certain traits and vary on certain traits (in the car example, they might all have the same engine-type and location of manufacture, but be different sizes and colors). For someone creating this [editable table] I would like to be able have the parent there to pass the overlapping traits on to their children, and have the children individually editable to fill in the traits on which they vary. However, for ease of manually copying and pasting large swaths of data into the treeview from external spreadsheets that only contain information on the children, I would like to have the parents (e.g., Toyota, Nissan) disappear. The best way to describe it would be turning the TreeView with parents and children into a TableView with only the lowest level children. What is the best approach? I'd like to toggle between the two views easily, which is why my initial idea was to simply maniuplate the TreeView. But I am definitely open to other ideas. I have read http://www.qtcentre.org/threads/4689...n-in-QTreeView and http://www.qtcentre.org/threads/2983...w-its-children . The first one doesn't work for me since there are multiple parents to hide, and the second one went unanswered. Any and all thoughts welcome! I can also explain what I'm looking for in more detail if it's not clear from what I already wrote, just let me know if you need more info.

    Edit:
    Would I be best served to apply a Proxy Model of some sort? I have had a hard time understanding how to use proxy models or what they do, so I'm not sure if that would be the appropriate application here...
    Last edited by ce_nort; 14th September 2016 at 23:01.

Similar Threads

  1. Hide parents in QSortFilterProxyModel if they don't match
    By Annihilator in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2014, 15:44
  2. QTreeView display of graph (multiple parents of item)
    By iraytrace in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2014, 20:34
  3. Hide children of QStandardItem in QTreeView
    By Phlucious in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2012, 21:48
  4. Hide Parent and show only children in QTreeView
    By y.s.bisht in forum Qt Programming
    Replies: 8
    Last Post: 19th January 2012, 10:51
  5. Replies: 0
    Last Post: 14th April 2010, 16:03

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.