[Qt-interest] Accessing the source model of a QSortFilterProxyModel after filtering

Bill KING bill.king at trolltech.com
Fri May 8 05:07:28 CEST 2009


Check out QAbstractProxyModel, especially mapTo/mapFrom functions.

Andreas Ntaflos wrote:
> Hi list, 
>
> I have a custom hierarchical tree model that provides several methods 
> for accessing an item's data (kind of like the record() method of a 
> QSqlQueryModel which returns the SQL record of a given item). I.e. 
> treeModel->type(QModelIndex &) returns the type of the item with the 
> given QModelIndex. This tree model is set as source model for a 
> QSortFilterProxyModel, which in turn is set as the model for a 
> QTreeView. 
>
> After the proxy model does its filtering I'd like to be able to call the 
> mentioned methods on the source model. Problem is: from where do I get 
> valid indexes to call e.g. the type() method on the source model? I 
> apparently can't use the indexes provided by the QTreeView's selection 
> model.
>
> So how do I create valid indexes I can use to access the source model 
> after the filtering?
>
> Hope this made sense :)
>
> Thanks in advance, 
>
> Andreas
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
Bill King, Software Engineer
Qt Software, Nokia Pty Ltd
Brisbane Office




More information about the Qt-interest-old mailing list