title: Using Qstring::toDouble To check data
body: <p>I'm trying to validate user input by using the <code>QString::toDouble()</code> function. The <a href="http://developer.qt.nokia.com/doc/qt-4.8/qstring.html#toDouble" rel="nofollow">documentation</a> says the function should be used like this:</p>
  
  <pre><code>double QString::toDouble ( bool * ok = 0 ) const;
  /* 
     Returns the string converted to a double value.
     Returns 0.0 if the conversion fails.
     If a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
  */
  </code></pre>
  
  <p>So I was trying to use the <code>*ok</code> to throw an error message if its false with the objective of only allowing users to enter valid integers or decimals. The problem is the message always returns valid even when words are entered. Here is my code so far:</p>
  
  <pre><code>void MainWindow::checkData()
  {        
      bool validate;
      QString tempStr;
      tempStr = ui-&gt;lineEditValidate-&gt;text();
      double converted = tempStr.toDouble(&amp;validate);
      if (validate = false)
      {
          QErrorMessage validateError;
          validateError.showMessage("Input is Invalid");
          validateError.exec();
      }
      else
      {
          QErrorMessage worksFine;
          worksFine.showMessage("valid");
          worksFine.exec();
      }
  }
  </code></pre>
  
  <p>I have a feeling that I am not passing the <code>validate</code> argument properly but the documentation isn't solid enough for me to really know; maybe the <code>QString::toDouble()</code> function is converting letters into values.</p>
  
  <p>Could someone explain where I've gone wrong?</p>