You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

kaiou.wang

Beginner

  • "kaiou.wang" started this thread

Posts: 3

Location: UK

Occupation: Design Engineer

  • Send private message

1

Tuesday, July 6th 2010, 12:54pm

QFileSystemModel update problem for shared network (samba) location

I'm using QFileSystemModel and QTreeView to display files tree from a shared network location (Samba).

Source code

1
2
3
Model->setRootPath("//HostName");
TreeView->setModel(Model);
TreeView->setRootIndex(Model->index("//HostName"));

The code works fine and I got the file tree. However, it can not automatically pick up the changes there. For example, if I create a new file there, the tree don't display this new file.

When I set the path to a directory on local hard drive, like "D:/temp". It works. It picks up the changes and update itself.

Any idea how can I pick up changes from a shared network location and refresh the model/tree?

Junior

Professional

  • "Junior" is male

Posts: 1,622

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

2

Tuesday, July 6th 2010, 1:59pm

QFileSystemModel along with QFileSystemWatcher are only for local host usage. Mounts and remote access will probably need to be handled differently through something like a threaded timer that might check the cksum of a mounted directory (quick check) thus calling the appropriate slot to update the directory contents of the view when detected change. Of course you can probably come up with other ways as well, but the bottom line is that this class was only intended for local host and not remote mounts.

kaiou.wang

Beginner

  • "kaiou.wang" started this thread

Posts: 3

Location: UK

Occupation: Design Engineer

  • Send private message

3

Tuesday, July 6th 2010, 2:21pm

Thanks, Junior. cksum check sounds a good idea.

Junior

Professional

  • "Junior" is male

Posts: 1,622

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

4

Tuesday, July 6th 2010, 2:55pm

Just note that cksum is for files, if you want to check the last access from a dir you might need to look into using stat library api on the system for getting information for directories.