evalspinbox wheel

This commit is contained in:
2021-03-05 18:38:52 +03:00
parent e82c77a6c5
commit cebed8eb2c
3 changed files with 18 additions and 3 deletions

View File

@@ -315,7 +315,7 @@ void EvalSpinBox::stepByDouble(double steps) {
if (eval->check(t)) {
t = eval->expression();
#if QT_VERSION_MAJOR <= 5
/* QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
int pos = 0;
if ((pos = re.indexIn(t)) != -1) {
double v = t.mid(pos, re.matchedLength()).toDouble();
@@ -326,9 +326,19 @@ void EvalSpinBox::stepByDouble(double steps) {
double v = steps;
t = QString::number(v) + t;
}
#else*/
#else
QRegularExpression re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
/// TODO andrey
QRegularExpressionMatchIterator i = re.globalMatch(t);
if (i.hasNext()) {
QRegularExpressionMatch match = i.next();
double v = t.mid(match.capturedStart(), match.capturedLength()).toDouble();
v += steps;
t.remove(match.capturedStart(), match.capturedLength());
t.insert(match.capturedStart(), QString::number(v));
} else {
double v = steps;
t = QString::number(v) + t;
}
#endif
eval->check(t);
lineEdit()->setText(eval->expression());