[Qt-interest] Question on QListView, QAbstractItemModel, and QSortFilterProxyModel
christopherx
christopherx at xandros.com
Wed Feb 18 22:27:10 CET 2009
I have tried with setRootIndex(current Modelindex); It only works
statically.
How can I make it work dynamically. I mean, if I click on the A, the
ListView will display A1, A2...; and if I click on B, then the ListView
will clean out the A, B, C, first, then displays B1, B2 ...
Thanks.
Chris
André Somers wrote:
> Hi Chris,
>
> "christopherx" <christopherx at xandros.com> schreef in bericht
> news:499A1383.4060001 at xandros.com...
>
>> Hello there:
>>
>> I'm a newbee to Qt,4, and have a question if you can help.
>> I have a data model built with QAbstractItemModel (subclassed from) in
>> a tree fashion (ie. RootItem has childrent A, B, and A has children C, C1,
>> and B has children D, D1 etc.. But I only like to display one level of
>> nodes at a time, ie (A, B or C, C1) with QListView. It seems not
>> possible.
>> And I tried with QSortFilterProxyModel, but no success; Any of you had
>> this issue before ? How to you handle this ?
>>
>
> You can use QListView::setRootIndex to do what you want, I think. Just set
> it to an invalid index using:
> myListView->setRootIndex(QModelIndex());
> to display the A, B, C nodes. If you want to display A1, A2...An, you set
> the root node to the index of node A.
>
> André
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Christopher Xu
Software Developer
*Xandros*
christopherx at xandros.com <mailto:christopherx at xandros.com>
Tel: 1.613.842.3498 x 403
http://www.xandros.com/
More information about the Qt-interest-old
mailing list