There are some 'similar' questions in stackoverflow, but can't quite implement them. In pyqt, I'm trying to pipe the output of a logfile (which is updating real-time) into a QTextEdit widget. The code I have so far is:
file = QFile('tmp')
fh = file.open(QIODevice.ReadOnly)
stream = QTextStream(file)
while not stream.atEnd():
line = stream.readLine()
self.logTextEdit.append(line)
file.close()
which processes the current contents, but not any subsequent changes. Ideally, a Qt signal would alert me to read another line as it's available and write it directly to TextEdit.
QFiledoes not emit such signals when others modify the file. In fact,QFiledoes not emit any signals period. Yes, it has them, but never emits them. You really wouldn't want it to happen by default, since on many systems file change notifications are very expensive and you'd pay that price on every file open through QFile. That would be really, really bad in practice. As far as I'm concerned, running Qt apps with lots of open files would be a nice denial-of-service against the machine they run on :) - Kuba hasn't forgotten Monica