Results 1 to 7 of 7

Thread: QTreeView and expandable items

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    20
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView and expandable items

    Quote Originally Posted by wysota View Post
    But it doesn't imply you should keep the state in the data model.
    I don't keep the current state, but only the default state in the XML -- how should the tree item be displayed when loaded.

    I don't know what the xml describes - does it describe items that are to be visualized using a tree view?
    Yes. Simple XML example:

    Qt Code:
    1. <browserTree name="MyTree">
    2. <treeNode name="RootNode" expanded="1">
    3. <treeNode name="ChildNode" expanded="1" />
    4. </treeNode>
    5. </browserTree>
    To copy to clipboard, switch view to plain text mode 


    Keep in mind that the model is only an interface to *any* data, nothing more, nothing less. If you have an XML file - don't read/parse/create structures. Just make your model operate on the XML directly. Otherwise you're ending up with an unnecessary redundancy and lag.
    Well the way the app is done right now, the parser (SaX) reads the XML file and creates the appropriate objects on the fly (for the GUI, those objects only describes the elements of the GUI to be generated. The view currently operate on the created objects.

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

    Default Re: QTreeView and expandable items

    Quote Originally Posted by SiLiZiUMM View Post
    The view currently operate on the created objects.
    You have redundancy then. Why not operate directly on the xml? How many items do you have? If the amount is not very big, you might use DOM instead of SAX and operate on the DOM tree directly. Of course I don't encourage you to do that if you already have a working SAX based version.

  3. #3
    Join Date
    May 2007
    Posts
    20
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView and expandable items

    Quote Originally Posted by wysota View Post
    You have redundancy then. Why not operate directly on the xml? How many items do you have? If the amount is not very big, you might use DOM instead of SAX and operate on the DOM tree directly. Of course I don't encourage you to do that if you already have a working SAX based version.
    That's exactly the situation: the parser class exists since a while and is part of another project, therefore cannot be swapped easily

    But thanks for the infos, very pleasing to read your posts as usual!

Similar Threads

  1. [QT4] QTreeView and expandable nodes
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2006, 16:52

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
  •  
Qt is a trademark of The Qt Company.