[Qt-interest] QDirModel v. QFileSystemModel ?

Girish Ramakrishnan girish at forwardbias.in
Mon Jun 15 05:30:33 CEST 2009


Stephen Collyer wrote:
> 2009/6/13 Girish Ramakrishnan <girish at forwardbias.in
> <mailto:girish at forwardbias.in>>
> 
>     Stephen Collyer wrote:
>     > Could someone explain the relative merits/demerits of these two
>     models ?
>     > The docs don't make it clear to me when one should be preferred
>     over the
>     > other (apart from the separate thread thing with QFileSystemModel).
>     >
> 
>     QFileSystemModel is like the successor to QDirModel.
> 
> 
> Does this imply that QDirModel is deprecated, or likely to be ?
>  

I guess it is not deprecated since it does have some use in the case of
views that don't ask the model to load dynamically (see below).

> 
>     Main advantage is
>     that it populates the model in a thread unlike QDirModel which does it
>     in the UI thread. As a consequence, one cannot arbitrarily query
>     information in a QFileSystemModel because the data may not be available
>     yet (unlike a QDirModel which will perform the operation synchronously).
>     In practice, this is not a problem when displaying the model in a view.
> 
> 
> Presumably the view triggers the model to load the required portion
> of the file system at the appropriate time ?
>  

Yes. It's using the canFetchMore/fetchMore API in the model.

Girish



More information about the Qt-interest-old mailing list