title: Check if timerID is valid in qt
body: <p>I am communicating with a remote device in qt, and sometimes the remote device is not answering. Therefore I implemented a timer which should notify the function <code>readData()</code> which is usually called when the device answers:</p>
  
  <pre><code>int timerID;
  
  void stepperMworker::start_timer()
  {
      this-&gt;timerID = startTimer(TIME_OUT);
  }
  
  void stepperMworker::readData(QString data)
  {
      killTimer(this-&gt;timerID);
      //Process data
  }
  
  void stepperMworker::timerEvent(QTimerEvent *event)
  {
      killTimer(this-&gt;timerID);
      this-&gt;readData(QString::number(-1));
  }
  </code></pre>
  
  <p>The idea was that either <code>readData()</code> is called first from the receiving signal from external, and then stops the timer, or the timer itself signalizes the <code>readData()</code>-function after <code>TIME_OUT</code> milliseconds that the external device is not responding. Nevertheless sometimes I get the error <code>Error: timer id 2 is not valid for object 0x98f270 (stepperMworker, ), timer has not been killed</code>. How can I determine if the current <code>timerID</code> is not valid?</p>