I have a QLineEdit which I use to get a double. But is there a more suitable way to get it? Here it is my code.
ui->lineEdit->setValidator(new QIntValidator(this));
QString XMAX=ui->lineEdit->text();
double xmax=XMAX.toDouble();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The canonical way to input a double is of course to use a QDoubleSpinBox.
If you insist on using a
QLineEdit, you should use it together with aQDoubleValidatorinstead of yourQIntValidator. I would just add a sanity check that something has been entered into the edit field: