PDA

View Full Version : Updating directory view in a QListView



Cruz
7th February 2009, 23:14
Hi there!

I'm trying to display the contents of a directory in a QListView. It works great like this:



QDirModel *model = new QDirModel;
ui.configFileList->setModel(model);
ui.configFileList->setRootIndex(model->index("config"));


But the view doesn't update when I write a file into that directory or drop something there in a file manager. I thought that was the whole model view thing all about. I also tried explicitly calling update() on the widget, nothing. Now after reading the docs and taking a look at the Directory View example to no avail, please help me to make my directory view update automagically.

wysota
7th February 2009, 23:48
Use QFileSystemModel instead of QDirModel. The former is kept up to date using QFileSystemWatcher.