PDA

View Full Version : Issue With QFileSystemModel ??



jesse_mark
25th March 2013, 15:02
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.

d_stranz
25th March 2013, 21:59
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.

jesse_mark
25th March 2013, 22:46
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.



void MainWindow::on_pushButton_open_clicked()
{
//open

file.setFileName("/home/test/log/test.log.txt");

if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(this, tr("Warning: Test File"),
tr("Cannot write file %1:\n%2.")
.arg("Test File")
.arg(file.errorString()));
return;
}
if (file.isOpen())
{
qDebug() << "file is opened";
}
// the signal is emitted, before i write or close the file.
}


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.