Results 1 to 6 of 6

Thread: How to group data in QTableView and show them in QTreeview ?

  1. #1
    Join Date
    May 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default How to group data in QTableView and show them in QTreeview ?

    Hi Dear,
    I have a tableView on my form, that contain data from database.
    I want to group data and show grouped data in a treeView, but i don't know how to do it !!
    Is there anybody help me ?

    Thanks a lot...

  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: How to group data in QTableView and show them in QTreeview ?

    Qt does not provide any built-in methods for aggregating data. Therefore you need to execute an sql query that will return aggregated data and build the tree model from it by yourself. If you sort incoming data by groups, then while iterating the result set, you can check whether the group of the current record is the same as that from the previous record and build your nodes based on that.
    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.


  3. #3
    Join Date
    May 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to group data in QTableView and show them in QTreeview ?

    Thank you...
    but i get data from database by query and don't have problem with it, i only don't know how do group data and put grouped data in QtreeView.
    I searched and found that could use of QAbstractitemmodel & QTreeView for grouping data !! but i don't know how !!?
    do you know how do i can use them ?

    thanks...

  4. #4
    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: How to group data in QTableView and show them in QTreeview ?

    Quote Originally Posted by Fatemeh View Post
    but i get data from database by query and don't have problem with it, i only don't know how do group data and put grouped data in QtreeView.
    By changing your query and building a tree model from the result.
    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.


  5. #5
    Join Date
    May 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to group data in QTableView and show them in QTreeview ?

    thank you very much for replies,
    If it's possible please explain to me more about it, i'm beginner with Qt so i'm don't know how do it !!

    Best regards...

  6. #6
    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: How to group data in QTableView and show them in QTreeview ?

    What is the part that you don't know how to implement?
    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. Qtreeview not displaying data (data() is called)
    By mraww in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2013, 20:19
  2. How to show two icon in QTreeView
    By Pardeep in forum Newbie
    Replies: 7
    Last Post: 11th February 2013, 13:52
  3. QTableView does not show data
    By waynew in forum Newbie
    Replies: 4
    Last Post: 11th December 2009, 23:38
  4. How to show progess in a QTreeView item ?
    By tanminh in forum Qt Programming
    Replies: 69
    Last Post: 3rd March 2008, 17:55
  5. Handling mass data with QTreeView/QTableView
    By alsuffndruff in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2006, 23:33

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.