Results 1 to 4 of 4

Thread: creating a tree hierarchy using QStandardModel

  1. #1
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default creating a tree hierarchy using QStandardModel

    I have a XML file with the following structure:
    Qt Code:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <isl_project_command>
    3. <task>
    4. <code>root</code>
    5. <parent_code></parent_code>
    6. <start_date>date</start_date>
    7. </task>
    8. <task>
    9. <code>child1</code>
    10. <parent_code>root</parent_code>
    11. <start_date>date</start_date>
    12. </task>
    13. <task>
    14. <code>child1.1</code>
    15. <parent_code>child1</parent_code>
    16. <start_date>date</start_date>
    17. </task>
    18. </isl_project_command>
    To copy to clipboard, switch view to plain text mode 

    Now i try to build a QStandardModel of this structure for displaying data in a QTreeView.
    The problem is i don't know how to create a hierarchy tree of the data.

    The tree should look something like this:

  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: creating a tree hierarchy using QStandardModel

    There is an example in QStandardItemModel docs how to build a tree using it. You can also search the forum here, I gave an example code to build a tree hierarchy using that model today.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: creating a tree hierarchy using QStandardModel

    And you want us to...? What have you tried so far?
    Tips:
    - search the forums, there's example pieces of code here and there
    - check the examples provided with Qt (examples/itemviews)
    - read QStandardItemModel docs once more (especially the detailed description part where's an example how to create a tree)

    Edit: the race is hard... yet another lose today
    Last edited by jpn; 19th September 2006 at 18:47.
    J-P Nurmi

  4. #4
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: creating a tree hierarchy using QStandardModel

    Quote Originally Posted by jpn View Post
    Edit: the race is hard... yet another lose today
    I wouldn't say that, it was your code that finally helped me to understand how the whole model/view thing works

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.