ifstream crashes ui?

I've been trying to use qt to watch text log files as lines are added and sadly haven't been able to get the results I've been looking for. So I starting to look for alternatives and found that ifstream works for what I'm trying to do, The fstream code works without issue when its ran in Visual studio without QT but when I go to add this code to QT and run the program the ui freezes and I get no errors. I thought it might of been the string to QString conversion but taking that out doesn't help.

the problem with with the code from the docs is that it stops reading the file when it hits the end. the file that I'm watching is a text file that is constantly being added. I did try to use QFileSystemWatcher but since the process that is writting the text file always has it open it doesn't let the fileChanged() signal to emit unless you manually open the directory and refresh it. I tried to use QDir::refresh on a timer to try and force the fileChange() signal to emit but with no luck. another thing I had tried was hooking up a timer to clear and reread the file, that works if I just want to read the file but if I want to set up an alert such as if(line = string){ QMessageBox::information(0, "alert", "in system");} I'll just get the same alert every time the function is called.

I'm with @SGaist, QSocketNotifier is appropriate for such things. QFileSystemWatcher will watch for changes in attributes or directory structure, but I don't believe it actually notifies on content changes, but I might be wrong.

Even if we accept, as the basic tenet of true democracy, that one moron is equal to one genius, is it necessary to go a further step and hold that two morons are better than one genius?

This signal is emitted when the file at the specified path is modified, renamed or removed from disk.

It does detect file content changes on Windows (using FindFirstChangeNotification and friends) and on Linux (using inotify). It also has OSX and BSD implementations too, but I haven't looked into how they work.

QSocketNotifiermight be the better option, but I'd certainly consider both. It would be an interesting exercise to put together a minimal example of both options to compare their subtleties :)

It does detect file content changes on Windows (using FindFirstChangeNotification and friends)

Well, MSDN doesn't mention a notification for the file being written as far as I could see, beside perhaps the size change or the last write time attribute. I don't know how responsive those are, but I suppose QFileSystemWatcher is a fair try.

It would be an interesting exercise to put together a minimal example of both options to compare their subtleties

Indeed.

Even if we accept, as the basic tenet of true democracy, that one moron is equal to one genius, is it necessary to go a further step and hold that two morons are better than one genius?