Results 1 to 5 of 5

Thread: QTreeView and QSortFilterProxyModel: On-demand model population

  1. #1
    Join Date
    May 2006
    Location
    Waterloo, ON
    Posts
    9
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QTreeView and QSortFilterProxyModel: On-demand model population

    I am using a QTreeView with a model that populates items with children on demand, i.e., only when the item is expanded. To achieve this, the model returns true for hasChildren() before the first expansion, while rowCount() returns 0.
    This worked well, until I tried to add a proxy between the model and the view, so that items could be filtered. The proxy returns false for hasChildren(), regardless of the result provided by the underlying model. This means that the expansion icons are not drawn, and the use can not open new items.

    Is there another way to force the tree to draw the expansion icons?

    Thanks,
    --Elad

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView and QSortFilterProxyModel: On-demand model population

    subclass the proxy and return true again in hasChildren() ?

  3. #3
    Join Date
    May 2006
    Location
    Waterloo, ON
    Posts
    9
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView and QSortFilterProxyModel: On-demand model population

    I wish it were that simple...
    QSortFilterProxyModel declares this method as non-virtual. That was the first thing I checked.

    --Elad

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView and QSortFilterProxyModel: On-demand model population

    yeeeeees.... BUT:
    it is virtual in the base class. A virtual method stays virtual, that's the point!
    (Whether the sub class re-declares the virtual is not important.)

  5. The following user says thank you to caduel for this useful post:

    elahav (6th February 2009)

  6. #5
    Join Date
    May 2006
    Location
    Waterloo, ON
    Posts
    9
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView and QSortFilterProxyModel: On-demand model population

    OK, thanks.
    I thought it had to be declared virtual in the immediate base class as well (I can certainly see a benefit to masking virtual functions, in order to ensure certain behaviour, but that's off-topic).

    --Elad

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.