Results 1 to 3 of 3

Thread: Issue With QFileSystemModel ??

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    48
    Thanked 2 Times in 2 Posts

    Default Issue With QFileSystemModel ??

    As I understand from the Docs on QFileSystemModel,
    when i set a rootpath to it , it will install a file system watcher on it. so any changes to this directory will be reflected on the module immediately.

    The issue im facing is:
    when I add files to this directory using other application, " log files generated by other application" , the watcher will not detect them which means the signal directoryChanged(QString) is not emitted . but if i add a file manually through a terminal the signal is emitted.

    Any ideas what else do i need to do, so the signal directoryChanged(QString) is emitted when files are added via another application ??

    Thanks.
    Last edited by jesse_mark; 25th March 2013 at 16:02.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Issue With QFileSystemModel ??

    You are monitoring a logging program, right? Are these log files still open and being written by the log program when you think you should be seeing the signal? What happens if you write a file with your own program? Does the signal get emitted when you first create the file, or only after you have written and then closed the file?

    You should be able to test this easily - make a simple dialog program with three pushbuttons. First button creates a file, second button writes something to it, third button closes it.

    Run your program with the file system watcher, then run the test program and see what happens when you click the buttons in order. This might give you a clue about what is happening with the log program.

  3. #3
    Join Date
    Jun 2012
    Posts
    173
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    48
    Thanked 2 Times in 2 Posts

    Default Re: Issue With QFileSystemModel ??

    Yes, you can say that i am monitoring a log program.

    make a simple dialog program with three pushbuttons.
    I made the small test program, the watcher emit the signal when I first create the file, even before i write or close it.

    Qt Code:
    1. void MainWindow::on_pushButton_open_clicked()
    2. {
    3. //open
    4.  
    5. file.setFileName("/home/test/log/test.log.txt");
    6.  
    7. if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
    8. QMessageBox::warning(this, tr("Warning: Test File"),
    9. tr("Cannot write file %1:\n%2.")
    10. .arg("Test File")
    11. .arg(file.errorString()));
    12. return;
    13. }
    14. if (file.isOpen())
    15. {
    16. qDebug() << "file is opened";
    17. }
    18. // the signal is emitted, before i write or close the file.
    19. }
    To copy to clipboard, switch view to plain text mode 

    so this make things even more strange to me, why the signal is not emitted when the other application is running ?

    the exact scenario is,
    I run another application_1 using my GUI_Application using Qprocess.
    after the application_1 is stared, it generates log files , where you can see the progress and the results.
    In my GUI_Application i watch the directory, using QFileSystemModel, where all the log files are generated.

    but the watcher does not emit signal when the log files are generated. IDK why?? The signal is not emitted even when the application_1, which write the log files, is finished.

Similar Threads

  1. QFileSystemModel::setFilter issue!!
    By kennylemon in forum Newbie
    Replies: 4
    Last Post: 29th June 2011, 10:37
  2. how use QFileSystemModel with QListView ?
    By lwifi in forum Qt Programming
    Replies: 4
    Last Post: 26th April 2010, 03:41
  3. Help with QFileSystemModel
    By TheShow in forum Qt Programming
    Replies: 4
    Last Post: 5th January 2010, 20:11
  4. QDirModel or QFileSystemModel?
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2009, 17:10
  5. QFileSystemModel has no sorting
    By mpi in forum Qt Programming
    Replies: 3
    Last Post: 28th May 2009, 08:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.