Last night I has asked for a validator to for checking if a number was an int and I got a good hand. One of my co-workers told me they're going to need a double. The code will throw an error for white space and for special characters so I'm not sure what the approach is. Thanks for the clarificatioin

Qt Code:
  1. double GateOverlapFactor::on_okButton_clicked()
  2. {
  3. QString isNumber = m_ui->lineEdit->text();
  4. QString trueNumber = "";
  5. QString str = m_ui->lineEdit->text();
  6. double returnDouble;
  7.  
  8. foreach(QChar c, str)
  9. {
  10. if(c.isNumber()) //check numeric input
  11. {
  12. trueNumber = m_ui->lineEdit->text();
  13.  
  14. close();
  15. }
  16. if(isspace(true)) // Check for whitespace
  17. {
  18. m_ui->messageLbl->setText(m_ui->lineEdit->text() + "Enter a Numeric Value");
  19. }
  20. else // not numeric?, throw error
  21. {
  22. m_ui->messageLbl->setText(m_ui->lineEdit->text() + ": Is Invalid. Enter a Numeric Value");
  23.  
  24. }
  25. }
  26.  
  27. returnDouble = trueNumber.toDouble();
  28.  
  29. return returnDouble;
  30. }
To copy to clipboard, switch view to plain text mode