Results 1 to 2 of 2

Thread: Restore QTreeView expanding

  1. #1
    Join Date
    Feb 2009
    Posts
    20

    Default Restore QTreeView expanding

    I want to restore the expanding of a TreeView.

    What would be the easiest approach?
    I'm thinking of something like, iterating through all QModelIndexes of the first column and storing the expanding flag of this Modelindex.

    Then I refill the tree and set the expanding settings to the same items, but only with the knowledge of the row and column number...

    what do you think?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Restore QTreeView expanding

    Yes, it should work. Provided you get the same tree as last time. Another approach would be to assign an ID to every node in the tree and store the list of IDs that are expanded. Then regardless of the shape of the tree when you restore the state, if IDs are kept, proper items will be expanded.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Need help Updating QTreeView model (QAbstractItemModel)
    By iraytrace in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2009, 23:49
  2. One Model, Two Views (QTreeView and QTableView)
    By dgarrett97 in forum Newbie
    Replies: 2
    Last Post: 14th September 2009, 19:10
  3. QTreeView restore Expanded node after reload model
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2008, 18:42
  4. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 22:22
  5. Replies: 1
    Last Post: 28th February 2007, 09:34

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.