View Full Version : QAbstractProxyModel for data grouping

3rd January 2013, 20:50
My question is about transforming flat data to the hierarchical model. Namely, I have a list of books described by the title, the author, etc. I want to be able to group books by some of those fields. In order to achieve this I subclass QAbstractProxyModel. It seems to work, but the items that represent categories (e.g. item with the name of the author containing books written by that author) can't be selected or edited. It seems like it is somehow related to the absence of the source index corresponding to the proxy index. I was trying to override the flags method, but it didn't help. I overrode proxy model's setData method, so in case category items are modified the source model is properly updated, and when I change proxy model programmatically it works fine, so my goal is just to make GUI to allow selecting and editing those items. What should I change for this purpose?

3rd January 2013, 21:11
What do your mapFromSource() and mapToSource() methods look like?