PDA

View Full Version : use QTreeView



totosugito
30th January 2008, 03:09
Dear,
I want make treeview like explorer.
I use this script :


QDirModel *model=new QDirModel;
treeView->setModel(model);
treeView->setRootIndex(model->index(QDir::currentPath()));

this script show all file and folder in currentpath.
my question are :
1. how to make treeView show all file not file and folder.
2. when i click file in treeview, i want statusbar show path and filename. I have path, but how to know name of file in current index.
3. i want to make treeview can rename and delete file. how to solve this program.

thank you. please help me.

regardly

toto

jpn
30th January 2008, 08:30
1. how to make treeView show all file not file and folder.

Take a look at QDirModel constructor docs. Especially notice the
QDir::Filters parameter.



2. when i click file in treeview, i want statusbar show path and filename. I have path, but how to know name of file in current index.

See QAbstractItemView::clicked() or QAbstractItemModel::data(). The former will get emitted whenever an item is clicked. By subclassing QDirModel and reimplementing the latter you could return data for Qt::StatusTipRole which would be automatically shown (presumably whenever an item is hovered, though).



3. i want to make treeview can rename and delete file. how to solve this program.

See QDirModel::readOnly.

PS. Have you noticed Extended Dir View example?

totosugito
30th January 2008, 09:33
thank for your answer
my problem is solved with Extended Dir View example

thank you