<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2021-02-22 11:13 a.m., Florian
Bruhin wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20210222161347.vc5vwbxrig5cmqk7@aragog.localdomain">
<pre class="moz-quote-pre" wrap="">Hey Stefan,
On Sun, Feb 21, 2021 at 11:41:58AM -0500, Stefan Seefeld wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">I'm trying to capture ("redirect") log data generated by a wrapped C++
library to a QTextEdit. The internet is full of related questions, but I
couldn't quite find a working example that matches my needs. I can configure
my logger to either write to the console (stdout) or to a file, so what I'm
looking for is a mechanism to attach a "listener" to the given file
descriptor and let it emit a `readyRead` signal whenever data are available.
For a reason I don't entirely understand, the `QFile` class does *not* emit
that signal, and thus is unfortunately unsuitable for this.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
I'm not sure why either, but FWIW that behavior is documented as well:
<a class="moz-txt-link-freetext" href="https://doc.qt.io/qt-5/qfile.html#signals">https://doc.qt.io/qt-5/qfile.html#signals</a></pre>
</blockquote>
<p>Indeed, I found that as well.<br>
</p>
<p>
</p>
<blockquote type="cite"
cite="mid:20210222161347.vc5vwbxrig5cmqk7@aragog.localdomain">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">So, does PyQt5 offer any classes that are equipped to listen to data being
written to a file descriptor such that I could read them asynchronously ?
The only examples I could find involve (tcp or udp) sockets or serial ports,
but not simple files...
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Despite the name, QSocketNotifier might work:
<a class="moz-txt-link-freetext" href="https://doc.qt.io/qt-5/qsocketnotifier.html">https://doc.qt.io/qt-5/qsocketnotifier.html</a>
("Although the class is called QSocketNotifier, it is normally used for
other types of devices than sockets")</pre>
</blockquote>
<p>Thanks ! Yes, I found that solution as well, and was able to
apply that to my case to make things work.</p>
<p>It would be nice to rename (or at least provide an alias to) the
QSocketNotifier, to clarify its usefulness with arbitrary file
descriptors.</p>
<p>Thank you for following up !</p>
<p>Best,</p>
<br>
<div class="moz-signature">
<div class="moz-signature">
<div class="moz-signature">
<pre><img moz-do-not-send="false" src="cid:part1.F196923C.B992F39F@seefeld.name" alt="Stefan" width="123" height="77">
--
...ich hab' noch einen Koffer in Berlin...
</pre>
</div>
</div>
</div>
</body>
</html>