[Qt-interest] QDirModel v. QFileSystemModel ?
Alexis Menard
alexis.menard at trolltech.com
Wed Jun 17 10:00:54 CEST 2009
Yes, please use the QFileSystemModel, better tests coverage, better
performance, better everything :D.
QDirModel is not deprecated but it doesn't receive that much love
because we have QFileSystemModel.
setRootPath move the QFileSystemModel to the root you want to. But of
course you have to limit the view by using
setRootIndex like you did, otherwise it will display from / (if linux)
all the time. It's because what ever the rootPath will
be in QFileSystemModel, it always create the hierarchy from the root
of the system. setRoothPath(/home/user/plop) will
create internally a root /, a child "home" of /, a child "user" of
home, and a child "plop" of user. That's why QTreeView will always
display from the top unless you call setRootIndex.
Hope it helps.
On Jun 17, 2009, at 09:51, Stephen Collyer wrote:
>
> 2009/6/16 David Boddie <david.boddie at nokia.com>
> Stephen Collyer wrote:
>
> > Also, why is there no equivalent of
> QFileSystemModel::setRootPath(..) ?
> > Does QDirModel always provide access to the whole file system ?
>
> Yes, but you can limit what is shown in the view:
>
> http://doc.qtsoftware.com/4.5/qdirmodel.html#details
>
>
> Right. I've also discovered that setRootPath(..) doesn't do what I
> expected
> anyway, and that it is vital that you limit what the view displays -
> AFAICS
> there is no other way to display only the contents of a subdirectory
> in a view,
> even when using QFileSystemModel.
>
> --
> Stephen Collyer
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090617/4fa38c3e/attachment.html
More information about the Qt-interest-old
mailing list