On 11/22/2013 02:31 PM, an...@familiesomers.nl wrote: > Bill Crocker schreef op 22.11.2013 20:19: >> Gang: >> >> I have created my own item model by sub-classing QAbstractItemModel. >> >> Functions like rowCount take a parent index so the model >> knows for which index it is being asked to return the count. >> This is good. >> >> My model is hierarchical and different points in the hierarchy >> have a different number of rows and (especially) columns. >> >> So, how come ::headerData is not passed an index so it knows for >> which parent index it is being asked to return the data? >> >> I'm using Qt 4.7.1 >> >> Bill >> > Because Qt does not support vertical headers for tree models (check > QTreeView, there is no vertical header there!) and it does not support > different columns for child items either. While theoretically it should > be possible (after all, QAbstractItemModel really models a nested grid), > the views simply do not support it. There are 3rd party add-ons that > provide more sophisticated views that can do this sort of thing, but the > basic Qt model/view system can't handle that. Qt doesn't even handle > cell spanning (QAbstractItemModel::span is not used.) >
I have been using Qt for a while. To work around this problem I sneak sufficient information into the model so the ::headerData function can compute the current effective root index. That has been working for years. For the first time in my Qt history I am now trying to position a QSortFilterProxyModel on top of my original model. (For the record: You can have no confidence in your item model implementation until you have used it with a proxy model (and that includes models which have been vetted by modeltest.h)) Anyway, apparently I am still doing something wrong because ::headerData is being called with a 'section' of -1. I am not telling you this with much hope of help (the context is too complicated for me to include a small example which demonstrates the problem). Just mention me in your prayers. :-) Bill > André > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest