[Qt-interest] QFileSystemModel and QTreeView interesting problemH
Denis Akhmetzyanov
dakhmetzyanov at smartlabs.tv
Tue Mar 30 15:26:21 CEST 2010
Or if you wish to make QDir::homePath() the root of the tree view you could
use:
QModelIndex index = treeModel->setRootPath(QDir::homePath());
treeView->setRootIndex(index);
// or
treeView->setRootIndex(treeModel->index(QDir::homePath()));
2010/3/30 Denis Akhmetzyanov <dakhmetzyanov at smartlabs.tv>
> Hi,
> Screenshot looks like only one column is visible and it is file
> modification (or creation) time. You could resize first column (filename)
> manually:
>
> QFileSystemModel *treeModel = new QFileSystemModel(this);
> QTreeView *treeView = new QTreeView(this);
> treeView->setModel(treeModel);
> QModelIndex index = treeModel->setRootPath(QDir::homePath());
> treeView->scrollTo(index);
> treeModel->setFilter(QDir::AllDirs | QDir::AllEntries | QDir::System |
> QDir::Hidden | QDir::NoDotAndDotDot);
> treeModel->setReadOnly(true);
>
> setCentralWidget(treeView);
> showMaximized();
> enum { FILENAME_COLUMN = 0 };
> treeView->setColumnWidth(FILENAME_COLUMN, 300);
>
> I've attached screenshots as it looks on my machine for Ubuntu 9.10, Qt
> 4.6.2 and WinXP, Qt 4.6.0.
>
>
> 2010/3/29 Andrei Sebastian Cimpean <andreiamenta at gmail.com>
>
> Hello again.
>> I tried your approach but got a similar result to the first problem, as
>> seen in
>> the screenshot.
>> I've attached another one also.
>> Any ideas?
>> Thanks!
>>
>> On Friday 26 March 2010 19:13:57 you wrote:
>> > 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/20100330/78e1d3eb/attachment.html
More information about the Qt-interest-old
mailing list