[Qt-interest] QFileSystemModel and QTreeView interesting problem

Denis Akhmetzyanov dakhmetzyanov at smartlabs.tv
Fri Mar 26 18:13:57 CET 2010


Hi,
QFileSystemModel::setRootPath doesn't scroll view to target path. Try this
code:

    m_treeModel = new QFileSystemModel(this);
    m_treeView = new QTreeView(this);
    m_treeView->setModel(m_treeModel);
    QModelIndex index = m_treeModel->setRootPath(QDir::homePath());
    m_treeView->scrollTo(index);
    m_treeModel->setFilter(QDir::AllDirs
|QDir::AllEntries|QDir::System|QDir::Hidden|QDir::NoDotAndDotDot);
    m_treeModel->setReadOnly(true);


2010/3/26 Andrei Cimpean <andreiamenta at gmail.com>

> Hello everybody.
>
> I am trying to display folders in a tree with this code:
>    treeModel = new QFileSystemModel;
>    m_ui->treeView->setModel(treeModel);
>    treeModel->setRootPath(QDir::homePath());//this displays /Users/andrei
>    treeModel->setFilter(QDir::AllDirs
> |QDir::AllEntries|QDir::System|QDir::Hidden|QDir::NoDotAndDotDot);
>    treeModel->setReadOnly(true);
>
> , but the result is:
>
>
> .
>
> Any ideas ?
> Thanks in advance.
> _______________________________________________
> 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/20100326/c9f52ac2/attachment.html 


More information about the Qt-interest-old mailing list