PDA

View Full Version : QDirModel



L.Marvell
29th May 2007, 14:56
I have two classes, one based on QTreeView (dirsView) and second on QListView (filesView). dirView has QDirModel with QDir::Drives | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks set and filesView with QDir::Files.
When directory is pressed dirsView emits directoryChanged(dirsModel->filePath(index)) and filesView connects this signal to slot with next code:
filesView->setRootIndex(filesModel->index(path));
Now, when I press on directory in dirsView, filesView shows files, all is OK. Then I press on subdirectory and again on previous directory, filesView shows files and subdirectory. So it shows every subdirectory that was pressed before. To change this I've inserted into slot next code:

filesModel->setFilter(QDir::Files);
filesView->setRootIndex(filesModel->index(path));

But isn't it hack? Is it possible to do it in another way?

marcel
29th May 2007, 18:30
A screen shot and some more code would help in providing an answer.

Regards

L.Marvell
5th June 2007, 14:47
You can look at example in attachment.