[Qt-interest] Help Tree view with Dir Model

J-P Nurmi jpnurmi at gmail.com
Fri May 14 09:41:25 CEST 2010


On Fri, May 14, 2010 at 8:52 AM, yogesh upreti <yogesh.upreti at gmail.com> wrote:
> Hello Everyone,
> I am using a tree view in my application to show the dir-structure. I am
> using the example given in Qt application:
>
> QDirModel dirModel;
> dirModel.setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
> ui->tempDirView->setModel(&dirModel);
> (tempDirView is a QTreeView object)
>
> now I want to expand this tree to the current dirctory, for that, I am using
> :
>
> QString pathFileView = QDir::currentPath(); (I am getting desired value
> here)
> QModelIndex ind =  this->dirModel.index(pathFileView);
> ui->tempDirView->setExpanded(ind, true);
>
> But this is not doing anything. Also I try to print ind.row() but this gives
> me 0
>
> Do you think this is a correct way to do that or there is a better/correct
> way for this?
>
> Thanks
> Yogesh

Perhaps this example helps:
http://www.qtcentre.org/wiki/index.php?title=Extended_Dir_View_example

--
J-P Nurmi




More information about the Qt-interest-old mailing list