[Qt-interest] Help Tree view with Dir Model

yogesh upreti yogesh.upreti at gmail.com
Fri May 14 07:52:51 CEST 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100514/93dfb27a/attachment.html 


More information about the Qt-interest-old mailing list