title: How to determine that I am at the "end" of a QIODevice?
body: <p>I am attempting to come up with an algorithm to detect when the "end" of a <a href="http://doc.qt.io/qt-5/qiodevice.html" rel="nofollow"><code>QIODevice</code></a> is reached (meaning no more data will ever be available for reading). Currently, my algorithm looks something like this:</p>
  
  <ul>
  <li>for sequential devices, wait for the <a href="http://doc.qt.io/qt-5/qiodevice.html#readChannelFinished" rel="nofollow"><code>readChannelFinished()</code></a> signal</li>
  <li>for regular files, continuously read data until <a href="http://doc.qt.io/qt-5/qiodevice.html#atEnd" rel="nofollow"><code>atEnd()</code></a> returns <code>true</code></li>
  </ul>
  
  <p>However, the documentation for <a href="http://doc.qt.io/qt-5/qiodevice.html#atEnd" rel="nofollow"><code>atEnd()</code></a> contains the following caveat:</p>
  
  <blockquote>
    <p>For some devices, atEnd() can return true even though there is more data to read. This special case only applies to devices that generate data in direct response to you calling read() (e.g., /dev or /proc files on Unix and OS X, or console input / stdin on all platforms).</p>
  </blockquote>
  
  <p>This is where my algorithm breaks down. My next idea was to continuously check the value of <a href="http://doc.qt.io/qt-5/qiodevice.html#bytesAvailable" rel="nofollow"><code>bytesAvailable()</code></a> when reading from a regular file. This yielded some very strange results for <code>/dev/zero</code>: <a href="http://doc.qt.io/qt-5/qiodevice.html#bytesAvailable" rel="nofollow"><code>bytesAvailable()</code></a> returned <code>0</code> until I invoked <a href="http://doc.qt.io/qt-5/qiodevice.html#read-2" rel="nofollow"><code>read(amount)</code></a>, at which point it indicated that there were <code>16384 - amount</code> bytes remaining.</p>
  
  <p>Is there any "proper" way to determine if there is still data available to read from a <a href="http://doc.qt.io/qt-5/qiodevice.html" rel="nofollow"><code>QIODevice</code></a>?</p>