Results 1 to 3 of 3

Thread: How to merge QTableView and QTreeView ???

  1. #1
    Join Date
    Apr 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to merge QTableView and QTreeView ???

    Hello everybody,

    I have a problem how to merge a QTableView and QTreeView.

    Originally, I have an SQL table of type:
    Qt Code:
    1. -------------------------------------------------
    2. | Name | Surname | Profession | Age
    3. -------------------------------------------------
    4. | John | Smith | Engineer | 25
    5. | Mike | Parrot | Designer | 35
    6. | Alex | Funny | Engineer | 45
    7. | Alex | Fellow | Designer | 29
    8. | Alice | Young | Secretary | 20
    9. --------------------------------------------------
    To copy to clipboard, switch view to plain text mode 
    The simplest way to represent data is to use QSqlTableModel and get a single table.

    My question is, if it is possible to merge QTableView and QTreeView and represent result as a tree of tables, based by one of the fields, e.g. by "Profession":
    Qt Code:
    1. +---Engineer:
    2. | -------------------------------------------------
    3. | | John | Smith | engineer | 25
    4. | | Alex | Funny | engineer | 45
    5. | -------------------------------------------------
    6. |
    7. +---Designer:
    8. | -------------------------------------------------
    9. | | Mike | Parrot | designer | 35
    10. | | Alex | Fellow | designer | 29
    11. | -------------------------------------------------
    12. |
    13. +---Secretary:
    14. -------------------------------------------------
    15. | Alice | Young | Secretary | 20
    16. -------------------------------------------------
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance for possible hints,
    Xaleandr

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to merge QTableView and QTreeView ???

    Yes, with a multicolumn model for the QTreeView.
    For an example take a look at the sources of QDirModel and the example Directory View, from the Item Views section. Another example is Interview from Qt Demos.

  3. #3
    Join Date
    Apr 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to merge QTableView and QTreeView ???

    Thanks a lot, I'll have a look.

Similar Threads

  1. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 12:08

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.