[PyQt] changing model for QTree
Brian Kelley
kelley at eyesopen.com
Wed Jan 28 23:21:01 GMT 2009
One easy solution to your issue is to use a QSortFilterProxyModel to "wrap" your model and only show the items you want visible.
>From the documentation:
QSortFilterProxyModel can be used for sorting items, filtering out items, or both. The model transforms the structure of a source model by mapping the model indexes it supplies to new indexes, corresponding to different locations, for views to use. This approach allows a given source model to be restructured as far as views are concerned without requiring any transformations on the underlying data, and without duplicating the data in memory.
Here is the documentation link:
http://doc.trolltech.com/4.4/qsortfilterproxymodel.html#details
There is a python example in
examples/itemview/basicsortfiltermodel.py
One word of caution, don't forget to turn the dynamicSortFilter property on!
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090128/5f79562d/attachment.html
More information about the PyQt
mailing list