title: Using QSocketNotifier to select on a char device.
body: <p>I wrote a char device driver and am now writing a QT "wrapper" which part of it is to get a signal to fire when the device becomes readable via the poll mechanism.  I had tried to do:</p>
  
  <pre><code>QFile file("/dev/testDriver");
  if(file.open(QFile::ReadOnly)) {
    QSocketNotifier sn(file.handle(), , QSocketNotifier::Read);
    sn.setEnabled(true);
    connect(&amp;sn, SIGNAL(activated(int)), &amp;this, SLOT(readyRead()));
  }
  </code></pre>
  
  <p>But readyRead was never called and my driver never reported having its poll method called.</p>
  
  <p>I was able to get the following code to work so I know my driver is working</p>
  
  <pre><code>QFile file("/dev/testDriver");
  if(file.open(QFile::ReadOnly)) {
      struct pollfd fd;
      fd.fd = file.handle();
      fd.events = POLLIN;
  
      struct pollfd fds[] = {fd};
      int ready;
      qDebug() &lt;&lt; "Started poll";
      ready = poll(fds, 1, -1);
      qDebug() &lt;&lt; "Poll returned: " &lt;&lt; ready;
  
      QTextStream in(&amp;file);
      QTextStream out(stdout);
      out &lt;&lt; in.readAll();
  }
  </code></pre>
  
  <p>This properly waits for my driver to call wake_up and I can see two poll calls from my driver. One for the initial poll registration and one for when the wake_up happens.  </p>
  
  <p>Doing it this way I would probably have to spawn a separate thread which all it did was poll on this device and throw a signal and loop. </p>
  
  <p>Is it possible to use <a href="http://doc.qt.nokia.com/latest/qsocketnotifier.html" rel="noreferrer">QSocketNotifier</a> in this way?  The documentation of <a href="http://doc.qt.nokia.com/latest/qfile.html#handle" rel="noreferrer">QFile::handle()</a> seems to indicate it should be.</p>