Results 1 to 11 of 11

Thread: Categorizing data.

  1. #1
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Categorizing data.

    Hi,

    I want to categorize data in a QTableView means... I have sorted a coluumn of a QtableView
    and i want to give sub headings to the data in the table.

    Like i have sorted on device type column and i need to paint sub headings on all devices according to device type group.

    see attachment.

    Please help..!!!!!!!

    Regards,
    Gk
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Categorizing data.

    Hi,

    Is there a solution to this?

    GK

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

    Default Re: Categorizing data.

    I think what you really want is QTreeView.

  4. #4
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Categorizing data.

    No i need to disply the data in tabular form. there are more columns apart from one shown in attachment. but the categorization is based on one column.

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

    Default Re: Categorizing data.

    Still you want a tree view because you want two levels of data - headers and body (similar to how Qt Designer displays widget properties).

  6. #6
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Categorizing data.

    ok... but how can i proceed ...
    some example code....

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

    Default Re: Categorizing data.

    Have a two level model - upper level for headers, lower level for items. Then apply the model to the tree view. Next you'll have to provide a custom delegate for your view to display the headers properly. Finally adjusting some properties of the view and expanding all the items will probably be needed

  8. #8
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Categorizing data.

    But the data that i have to display is already in a model which is derived from QAbstract ProxyModel.

    Do i have to replicate the data..but that would be bad..

    Is there some reference material..?

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

    Default Re: Categorizing data.

    You don't have to replicate data. Just make your proxy restructurize it into two level hierarchy.

  10. #10
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Categorizing data.

    Thanks...
    Theoretically it is ok ..but how do i put it in code..?

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

    Default Re: Categorizing data.

    You'll have to change your parent(), index(), rowCount() and data() methods. The top level items are artificial so you can't map them to source indexes, thus you have to provide implementations for above mentioned methods for them. rowCount() for the top level (invalid parent) will return the number of groups (headers) and for the lower levels (parent points to group item) the number of items in a particular group. Same goes for the remaining methods.

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 03:59
  2. Replies: 4
    Last Post: 19th October 2007, 19:47
  3. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 12:14
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.