- aEditor->setValidator(new QDoubleValidator(aEditor));
- QObject::connect(aEditor, SIGNAL(returnPressed()), &aDlg, SLOT(accept()));
- aLay->addWidget(aEditor);
-
- QPoint aPoint = QCursor::pos();
- aDlg.move(aPoint);
-
- isDone = aDlg.exec() == QDialog::Accepted;
- double aValue = theValue;
- if (isDone)
- aValue = aEditor->text().toDouble();
- return aValue;
+ QString anExpression("([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)|([_a-zA-Z][a-zA-Z0-9_]*)");
+ aEditor->setValidator(new QRegExpValidator(QRegExp(anExpression), aEditor));
+ QObject::connect(aEditor, SIGNAL(returnPressed()), aLineEditAction, SIGNAL(triggered()));
+ QObject::connect(aLineEditAction, SIGNAL(triggered()), aPopup, SLOT(hide()));
+
+ QAction* aResult = aPopup->exec(QCursor::pos());
+ outText = aEditor->text();
+ bool isDouble;
+ double aValue = outText.toDouble(&isDouble);
+ if (isDouble) {
+ outValue = aValue;
+ outText = ""; // return empty string, if it's can be converted to a double
+ }
+ aPopup->deleteLater();