Results 1 to 6 of 6

Thread: Dynamic Grouping of QTableView Rows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: Dynamic Grouping of QTableView Rows

    Maybe check this article about an identity proxy model by one of the kde guys. You might want to check that out and see if it gives you a nudge in the right direction.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  2. #2
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    18
    Thanked 5 Times in 5 Posts

    Default Re: Dynamic Grouping of QTableView Rows

    Thanks, Franz.

    I spent some time last night going through the KDEUI lib and I found the KIdentityProxyModel and the KCategorizedSortFilterProxyModel, but unfortunately I don't see how they are going to help me yet. But they have given me some ideas.

    I have an underlying CAbstractListModel with an attached QTableView. What I'd like to do is view the data from a list model in a QTreeView with arbitrary grouping defined by the user. The user should be able to specify a column (only one at a time, i.e. no nested grouping) to group by and then each unique value in that column would become a new parent node with the relevant original rows are children. Also the "group by" column would be hidden. I found an working online ASP.NET example of the kind of functionality I'm talking about here.

    Maybe what I need to do is have a proxy model (inheriting from QSortFilterProxyModel perhaps) on top of the list model which provides extra functionality that is required by the QTreeView, e.g.

    QModelIndex parent(const QModelIndex &index) const;

    I want to create a generic solution because I have a few tables in my application that would benefit from this functionality. Unfortunately the priority of this job is not high at all so I'm not able to give it too much time right now. I'll post back with further ideas, progress, etc.

  3. #3
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    18
    Thanked 5 Times in 5 Posts

    Default Re: Dynamic Grouping of QTableView Rows

    I did some more searching and found this wiki entry, [WIKI]Transpose_proxy_model[/WIKI].

    I might just be getting closer to a possible answer. Having a specialised QAbstractProxyModel that is able to provide a QTreeView with the relevant hierarchical information could work. The trick is going to be working out the hierarchical details from a non-hierarchical model.

    I'm going to have to just try it out and see what happens.

Similar Threads

  1. Replies: 2
    Last Post: 23rd November 2010, 05:43
  2. Dynamic form layout - Ability to add new rows
    By FaradayCage in forum Newbie
    Replies: 1
    Last Post: 22nd July 2010, 16:23
  3. Replies: 0
    Last Post: 22nd April 2010, 13:18
  4. QTableView 2 rows inside every row
    By skuda in forum Qt Programming
    Replies: 3
    Last Post: 22nd April 2009, 09:23
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

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