[Qt-interest] setRootPath() on QFileSystemModel not working [SOLVED]
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Tue Jun 29 10:34:26 CEST 2010
I had to do this additional stuff:
QModelIndex idx = model.setRootPath("/home/mandeep/test");
...
...
view.setRootIndex(idx);
It works now. Though having to set the root index is NOT very intuitive.
I was expecting setRootPath() to initialize the root index to be set
to pointing to the path given.
Regards,
-mandeep
On Tue, Jun 29, 2010 at 1:35 PM, Mandeep Sandhu
<mandeepsandhu.chd at gmail.com> wrote:
> I have some very simple code to show dir listings in a tree view:
>
> <snip>
> ...
> QFileSystemModel model;
> QTreeView view;
>
> model.setRootPath("/home/mandeep/test/");
>
> view.setModel(&model);
> view.show();
> ...
> </snip>
>
> When I run this, the tree view is showing me dir's from my systems
> root dir, i.e "/" and not "/home/mandeep/test/" as I'd set it.
>
> Calling model.rootPath() shows the root path to what I'd set.
>
> Is there something I'm missing? Why does it show files from the root
> nad not from where I specify?
>
> I'm using Ubuntu 10.04.
>
> This seemed to be trivial task and now I'm stuck! :)
>
> Thanks,
> -mandeep
>
More information about the Qt-interest-old
mailing list