Results 1 to 2 of 2

Thread: How can I display only the children of a QTreeView?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2021
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Question How can I display only the children of a QTreeView?

    I want to add a checkbox toggle to my application where a tree view gets flattened to show only the leafs nodes (child items with no children). When the toggle is unselected it should go back to the original treeview.

    Something like this:

    A
    -B
    -C
    -D
    -E
    -F
    -G
    -H
    -I
    -K

    Should become

    -C
    -E
    -F
    -K

    The desired outcome should be similar to doing setIndentation(0) when the check box is toggled and setIndentation(20) when unchecked but only the children should be visible when checked and back to the original treeview when unchecked.

    Other similar questions use KDE's KDescendantsProxyModel but for that you provide the depth level to show but in my case children can be at any depth level. And I am ideally looking for a solution involving only Qt APIs.

    Is there a way I can use QSortProxyFilters to accomplish this?

    Any thoughts/ suggestions?
    Last edited by donnaroma; 16th June 2021 at 21:26.

Similar Threads

  1. How to set widgets as children items on QTreeView
    By q130s in forum Qt Programming
    Replies: 3
    Last Post: 10th March 2013, 00:40
  2. QTreeView children with multiple coulms
    By maxpower in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2012, 15:10
  3. Hide children of QStandardItem in QTreeView
    By Phlucious in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2012, 21:48
  4. QTreeView adding children to the view
    By Tux-Slack in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2007, 10:28
  5. QTreeView and QStandardModel : add children
    By Valheru in forum Newbie
    Replies: 7
    Last Post: 19th September 2006, 18:24

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.