title: waiting a few seconds in Qt
body: <p>My knowledge of threading in Qt is rather limited, and I have a problem now that seems to be related to threading. I'm using QextSerialPort for communication over a uart. My class for serial communication looks like this (stripped to the minimum):</p>
  
  <pre><code>SerialIO::SerialIO() {
      port = new QextSerialPort("/dev/ttymxc1");
      connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
      port-&gt;setQueryMode(QextSerialPort::EventDriven);
      port-&gt;open(QIODevice::ReadWrite | QIODevice::Unbuffered);
      port-&gt;setBaudRate(BAUD115200);
      port-&gt;setFlowControl(FLOW_OFF);
      port-&gt;setParity(PAR_NONE);
      port-&gt;setDataBits(DATA_8);
      port-&gt;setStopBits(STOP_1);
  }
  
  void SerialIO::initialize() {
      // do something
  
      // wait for 15 s
  
      // do something else
  }
  
  void SerialIO::onDataAvailable() {
      // do something useful
  }
  </code></pre>
  
  <p>The problem is waiting for 15 s in the <code>initialize()</code> method without blocking serial input. I tried</p>
  
  <pre><code>QThread::sleep(15)
  </code></pre>
  
  <p>and even</p>
  
  <pre><code>QTime time;
  time.start();
  while(time.elapsed() &lt; 15000); // evil busy wait
  </code></pre>
  
  <p>But with both attempts, I stopped getting serial data (<code>onDataAvailable</code> was no longer called during those 15 seconds). What is the correct way to do this?</p>