Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qspinbox.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <private/qabstractspinbox_p.h>
5#include <qspinbox.h>
6
7#include <qlineedit.h>
8#include <qlocale.h>
9#include <qvalidator.h>
10#include <qdebug.h>
11
12#include <algorithm>
13#include <cmath>
14#include <float.h>
15
17
18using namespace Qt::StringLiterals;
19
20//#define QSPINBOX_QSBDEBUG
21#ifdef QSPINBOX_QSBDEBUG
22# define QSBDEBUG qDebug
23#else
24# define QSBDEBUG if (false) qDebug
25#endif
26
28{
29 Q_DECLARE_PUBLIC(QSpinBox)
30public:
32 void emitSignals(EmitPolicy ep, const QVariant &) override;
33
34 virtual QVariant valueFromText(const QString &n) const override;
35 virtual QString textFromValue(const QVariant &n) const override;
38
39 inline void init() {
40 Q_Q(QSpinBox);
41 q->setInputMethodHints(Qt::ImhDigitsOnly);
43 }
44
46
47 QVariant calculateAdaptiveDecimalStep(int steps) const override;
48};
49
51{
52 Q_DECLARE_PUBLIC(QDoubleSpinBox)
53public:
55 void emitSignals(EmitPolicy ep, const QVariant &) override;
56
57 virtual QVariant valueFromText(const QString &n) const override;
58 virtual QString textFromValue(const QVariant &n) const override;
61 double round(double input) const;
62 // variables
64
65 inline void init() {
66 Q_Q(QDoubleSpinBox);
67 q->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
68 }
69
70 // When fiddling with the decimals property, we may lose precision in these properties.
71 double actualMin;
72 double actualMax;
73
74 QVariant calculateAdaptiveDecimalStep(int steps) const override;
75};
76
77
166 : QAbstractSpinBox(*new QSpinBoxPrivate, parent)
167{
168 Q_D(QSpinBox);
169 d->init();
170}
171
176
187{
188 Q_D(const QSpinBox);
189 return d->value.toInt();
190}
191
193{
194 Q_D(QSpinBox);
195 d->setValue(QVariant(value), EmitIfChanged);
196}
197
218{
219 Q_D(const QSpinBox);
220 return d->prefix;
221}
222
223void QSpinBox::setPrefix(const QString &prefix)
224{
225 Q_D(QSpinBox);
226
227 d->prefix = prefix;
228 d->updateEdit();
229
230 d->cachedSizeHint = QSize();
231 d->cachedMinimumSizeHint = QSize(); // minimumSizeHint cares about the prefix
233}
234
255{
256 Q_D(const QSpinBox);
257
258 return d->suffix;
259}
260
261void QSpinBox::setSuffix(const QString &suffix)
262{
263 Q_D(QSpinBox);
264
265 d->suffix = suffix;
266 d->updateEdit();
267
268 d->cachedSizeHint = QSize();
270}
271
282{
283 Q_D(const QSpinBox);
284
285 return d->stripped(d->edit->displayText());
286}
287
288
300{
301 Q_D(const QSpinBox);
302
303 return d->singleStep.toInt();
304}
305
307{
308 Q_D(QSpinBox);
309 if (value >= 0) {
310 d->singleStep = QVariant(value);
311 d->updateEdit();
312 }
313}
314
329{
330 Q_D(const QSpinBox);
331
332 return d->minimum.toInt();
333}
334
335void QSpinBox::setMinimum(int minimum)
336{
337 Q_D(QSpinBox);
338 const QVariant m(minimum);
339 d->setRange(m, (QSpinBoxPrivate::variantCompare(d->maximum, m) > 0 ? d->maximum : m));
340}
341
357{
358 Q_D(const QSpinBox);
359
360 return d->maximum.toInt();
361}
362
363void QSpinBox::setMaximum(int maximum)
364{
365 Q_D(QSpinBox);
366 const QVariant m(maximum);
367 d->setRange((QSpinBoxPrivate::variantCompare(d->minimum, m) < 0 ? d->minimum : m), m);
368}
369
381void QSpinBox::setRange(int minimum, int maximum)
382{
383 Q_D(QSpinBox);
384 d->setRange(QVariant(minimum), QVariant(maximum));
385}
386
410{
411 Q_D(QSpinBox);
412 d->stepType = stepType;
413}
414
423{
424 Q_D(const QSpinBox);
425 return d->stepType;
426}
427
440{
441 Q_D(const QSpinBox);
442 return d->displayIntegerBase;
443}
444
446{
447 Q_D(QSpinBox);
448 // Falls back to base 10 on invalid bases (like QString)
449 if (Q_UNLIKELY(base < 2 || base > 36)) {
450 qWarning("QSpinBox::setDisplayIntegerBase: Invalid base (%d)", base);
451 base = 10;
452 }
453
454 if (base != d->displayIntegerBase) {
455 d->displayIntegerBase = base;
456 d->updateEdit();
457 }
458}
459
479{
480 Q_D(const QSpinBox);
481 QString str;
482
483 if (d->displayIntegerBase != 10) {
484 const auto prefix = value < 0 ? "-"_L1 : ""_L1;
485 str = prefix + QString::number(qAbs(value), d->displayIntegerBase);
486 } else {
488 if (!d->showGroupSeparator && (qAbs(value) >= 1000 || value == INT_MIN)) {
489 str.remove(locale().groupSeparator());
490 }
491 }
492
493 return str;
494}
495
512{
513 Q_D(const QSpinBox);
514
515 QString copy = text;
516 int pos = d->edit->cursorPosition();
518 return d->validateAndInterpret(copy, pos, state).toInt();
519}
520
525{
526 Q_D(const QSpinBox);
527
529 d->validateAndInterpret(text, pos, state);
530 return state;
531}
532
533
538{
540 input.remove(locale().groupSeparator());
541}
542
543
544// --- QDoubleSpinBox ---
545
627{
628 Q_D(QDoubleSpinBox);
629 d->init();
630}
631
636
651{
652 Q_D(const QDoubleSpinBox);
653
654 return d->value.toDouble();
655}
656
658{
659 Q_D(QDoubleSpinBox);
660 QVariant v(d->round(value));
661 d->setValue(v, EmitIfChanged);
662}
683{
684 Q_D(const QDoubleSpinBox);
685
686 return d->prefix;
687}
688
690{
691 Q_D(QDoubleSpinBox);
692
693 d->prefix = prefix;
694 d->updateEdit();
695
696 d->cachedSizeHint = QSize();
697 d->cachedMinimumSizeHint = QSize(); // minimumSizeHint cares about the prefix
699}
700
721{
722 Q_D(const QDoubleSpinBox);
723
724 return d->suffix;
725}
726
728{
729 Q_D(QDoubleSpinBox);
730
731 d->suffix = suffix;
732 d->updateEdit();
733
734 d->cachedSizeHint = QSize();
736}
737
748{
749 Q_D(const QDoubleSpinBox);
750
751 return d->stripped(d->edit->displayText());
752}
753
764{
765 Q_D(const QDoubleSpinBox);
766
767 return d->singleStep.toDouble();
768}
769
771{
772 Q_D(QDoubleSpinBox);
773
774 if (value >= 0) {
775 d->singleStep = value;
776 d->updateEdit();
777 }
778}
779
797{
798 Q_D(const QDoubleSpinBox);
799
800 return d->minimum.toDouble();
801}
802
803void QDoubleSpinBox::setMinimum(double minimum)
804{
805 Q_D(QDoubleSpinBox);
806 d->actualMin = minimum;
807 const QVariant m(d->round(minimum));
808 d->setRange(m, (QDoubleSpinBoxPrivate::variantCompare(d->maximum, m) > 0 ? d->maximum : m));
809}
810
828{
829 Q_D(const QDoubleSpinBox);
830
831 return d->maximum.toDouble();
832}
833
834void QDoubleSpinBox::setMaximum(double maximum)
835{
836 Q_D(QDoubleSpinBox);
837 d->actualMax = maximum;
838 const QVariant m(d->round(maximum));
839 d->setRange((QDoubleSpinBoxPrivate::variantCompare(d->minimum, m) < 0 ? d->minimum : m), m);
840}
841
856void QDoubleSpinBox::setRange(double minimum, double maximum)
857{
858 Q_D(QDoubleSpinBox);
859 d->actualMin = minimum;
860 d->actualMax = maximum;
861 d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum)));
862}
863
890{
891 Q_D(QDoubleSpinBox);
892 d->stepType = stepType;
893}
894
903{
904 Q_D(const QDoubleSpinBox);
905 return d->stepType;
906}
907
924{
925 Q_D(const QDoubleSpinBox);
926
927 return d->decimals;
928}
929
931{
932 Q_D(QDoubleSpinBox);
933 d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG);
934
935 setRange(d->actualMin, d->actualMax); // make sure values are rounded
936 setValue(value());
937}
938
958{
959 Q_D(const QDoubleSpinBox);
960 QString str = locale().toString(value, 'f', d->decimals);
961 if (!d->showGroupSeparator && qAbs(value) >= 1000.0)
962 str.remove(locale().groupSeparator());
963
964 return str;
965}
966
980{
981 Q_D(const QDoubleSpinBox);
982
983 QString copy = text;
984 int pos = d->edit->cursorPosition();
986 return d->validateAndInterpret(copy, pos, state).toDouble();
987}
988
993{
994 Q_D(const QDoubleSpinBox);
995
997 d->validateAndInterpret(text, pos, state);
998 return state;
999}
1000
1001
1006{
1007 input.remove(locale().groupSeparator());
1008}
1009
1010// --- QSpinBoxPrivate ---
1011
1018{
1019 minimum = QVariant((int)0);
1020 maximum = QVariant((int)99);
1021 value = minimum;
1022 displayIntegerBase = 10;
1023 singleStep = QVariant((int)1);
1024 type = QMetaType::Int;
1025}
1026
1033{
1034 Q_Q(QSpinBox);
1035 if (ep != NeverEmit) {
1036 pendingEmit = false;
1037 if (ep == AlwaysEmit || value != old) {
1038 emit q->textChanged(edit->displayText());
1039 emit q->valueChanged(value.toInt());
1040 }
1041 }
1042}
1043
1050{
1051 Q_Q(const QSpinBox);
1052 return q->textFromValue(value.toInt());
1053}
1060{
1061 Q_Q(const QSpinBox);
1062
1063 return QVariant(q->valueFromText(text));
1064}
1065
1066
1074 QValidator::State &state) const
1075{
1076 if (cachedText == input && !input.isEmpty()) {
1078 QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
1079 << state << " and value was " << cachedValue;
1080
1081 return cachedValue;
1082 }
1083 const int max = maximum.toInt();
1084 const int min = minimum.toInt();
1085
1087 QSBDEBUG() << "input" << input << "copy" << copy;
1089 int num = min;
1090
1091 if (max != min && (copy.isEmpty()
1092 || (min < 0 && copy == "-"_L1)
1093 || (max >= 0 && copy == "+"_L1))) {
1095 QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
1096 } else if (copy.startsWith(u'-') && min >= 0) {
1097 state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100
1098 } else {
1099 bool ok = false;
1100 if (displayIntegerBase != 10) {
1101 num = copy.toInt(&ok, displayIntegerBase);
1102 } else {
1103 num = locale.toInt(copy, &ok);
1104 if (!ok && (max >= 1000 || min <= -1000)) {
1106 const QString doubleSep = sep + sep;
1107 if (copy.contains(sep) && !copy.contains(doubleSep)) {
1108 QString copy2 = copy;
1109 copy2.remove(sep);
1110 num = locale.toInt(copy2, &ok);
1111 }
1112 }
1113 }
1114 QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
1115 if (!ok) {
1117 } else if (num >= min && num <= max) {
1119 } else if (max == min) {
1121 } else {
1122 if ((num >= 0 && num > max) || (num < 0 && num < min)) {
1124 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1125 } else {
1127 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate";
1128 }
1129 }
1130 }
1132 num = max > 0 ? min : max;
1133 input = prefix + copy + suffix;
1134 cachedText = input;
1136 cachedValue = QVariant((int)num);
1137
1138 QSBDEBUG() << "cachedText is set to '" << cachedText << "' state is set to "
1139 << state << " and value is set to " << cachedValue;
1140 return cachedValue;
1141}
1142
1144{
1145 const int intValue = value.toInt();
1146 const int absValue = qAbs(intValue);
1147
1148 if (absValue < 100)
1149 return 1;
1150
1151 const bool valueNegative = intValue < 0;
1152 const bool stepsNegative = steps < 0;
1153 const int signCompensation = (valueNegative == stepsNegative) ? 0 : 1;
1154
1155 const int log = static_cast<int>(std::log10(absValue - signCompensation)) - 1;
1156 return static_cast<int>(std::pow(10, log));
1157}
1158
1159// --- QDoubleSpinBoxPrivate ---
1160
1167{
1168 actualMin = 0.0;
1169 actualMax = 99.99;
1172 value = minimum;
1173 singleStep = QVariant(1.0);
1174 decimals = 2;
1175 type = QMetaType::Double;
1176}
1177
1184{
1185 Q_Q(QDoubleSpinBox);
1186 if (ep != NeverEmit) {
1187 pendingEmit = false;
1188 if (ep == AlwaysEmit || value != old) {
1189 emit q->textChanged(edit->displayText());
1190 emit q->valueChanged(value.toDouble());
1191 }
1192 }
1193}
1194
1195
1201{
1202 Q_Q(const QDoubleSpinBox);
1203 return QVariant(q->valueFromText(f));
1204}
1205
1215{
1216 return QString::number(value, 'f', decimals).toDouble();
1217}
1218
1219
1227 QValidator::State &state) const
1228{
1229 if (cachedText == input && !input.isEmpty()) {
1231 QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
1232 << state << " and value was " << cachedValue;
1233 return cachedValue;
1234 }
1235 const double max = maximum.toDouble();
1236 const double min = minimum.toDouble();
1237
1239 QSBDEBUG() << "input" << input << "copy" << copy;
1240 int len = copy.size();
1241 double num = min;
1242 const bool plus = max >= 0;
1243 const bool minus = min <= 0;
1244
1246 const uint groupUcs = (group.isEmpty() ? 0 :
1247 (group.size() > 1 && group.at(0).isHighSurrogate()
1248 ? QChar::surrogateToUcs4(group.at(0), group.at(1))
1249 : group.at(0).unicode()));
1250 switch (len) {
1251 case 0:
1253 goto end;
1254 case 1:
1255 if (copy.at(0) == locale.decimalPoint()
1256 || (plus && copy.at(0) == u'+')
1257 || (minus && copy.at(0) == u'-')) {
1259 goto end;
1260 }
1261 break;
1262 case 2:
1263 if (copy.at(1) == locale.decimalPoint()
1264 && ((plus && copy.at(0) == u'+') || (minus && copy.at(0) == u'-'))) {
1266 goto end;
1267 }
1268 break;
1269 default: break;
1270 }
1271
1272 if (groupUcs && copy.startsWith(group)) {
1273 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1275 goto end;
1276 } else if (len > 1) {
1277 const int dec = copy.indexOf(locale.decimalPoint());
1278 if (dec != -1) {
1279 if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) {
1280 copy.remove(dec + 1, 1); // typing a delimiter when you are on the delimiter
1281 } // should be treated as typing right arrow
1282
1283 if (copy.size() - dec > decimals + 1) {
1284 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1286 goto end;
1287 }
1288 for (int i = dec + 1; i < copy.size(); ++i) {
1289 if (copy.at(i).isSpace()
1290 || (groupUcs && QStringView{copy}.sliced(i).startsWith(group))) {
1291 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1293 goto end;
1294 }
1295 }
1296 } else {
1297 const QChar last = copy.back();
1298 const bool groupEnd = groupUcs && copy.endsWith(group);
1299 const QStringView head(copy.constData(), groupEnd ? len - group.size() : len - 1);
1300 const QChar secondLast = head.back();
1301 if ((groupEnd || last.isSpace())
1302 && ((groupUcs && head.endsWith(group)) || secondLast.isSpace())) {
1304 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1305 goto end;
1306 } else if (last.isSpace() && (!QChar::isSpace(groupUcs) || secondLast.isSpace())) {
1308 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1309 goto end;
1310 }
1311 }
1312 }
1313
1314 {
1315 bool ok = false;
1316 num = locale.toDouble(copy, &ok);
1317 QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok;
1318
1319 if (!ok) {
1320 if (QChar::isPrint(groupUcs)) {
1321 if (max < 1000 && min > -1000 && groupUcs && copy.contains(group)) {
1323 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1324 goto end;
1325 }
1326
1327 const int len = copy.size();
1328 for (int i = 0; i < len - 1;) {
1329 if (groupUcs && QStringView{copy}.sliced(i).startsWith(group)) {
1330 if (QStringView(copy).mid(i + group.size()).startsWith(group)) {
1331 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1333 goto end;
1334 }
1335 i += group.size();
1336 } else {
1337 i++;
1338 }
1339 }
1340
1341 QString copy2 = copy;
1342 if (groupUcs)
1343 copy2.remove(group);
1344 num = locale.toDouble(copy2, &ok);
1345 QSBDEBUG() << group << num << copy2 << ok;
1346
1347 if (!ok) {
1349 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1350 goto end;
1351 }
1352 }
1353 }
1354
1355 if (!ok) {
1357 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1358 } else if (num >= min && num <= max) {
1360 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Acceptable";
1361 } else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min)
1363 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1364 } else {
1365 if ((num >= 0 && num > max) || (num < 0 && num < min)) {
1367 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1368 } else {
1370 QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate";
1371 }
1372 }
1373 }
1374
1375end:
1377 num = max > 0 ? min : max;
1378 }
1379
1380 input = prefix + copy + suffix;
1381 cachedText = input;
1384 return QVariant(num);
1385}
1386
1387/*
1388 \internal
1389 \reimp
1390*/
1391
1393{
1394 Q_Q(const QDoubleSpinBox);
1395 return q->textFromValue(f.toDouble());
1396}
1397
1399{
1400 const double doubleValue = value.toDouble();
1401 const double minStep = std::pow(10, -decimals);
1402 double absValue = qAbs(doubleValue);
1403
1404 if (absValue < minStep)
1405 return minStep;
1406
1407 const bool valueNegative = doubleValue < 0;
1408 const bool stepsNegative = steps < 0;
1409 if (valueNegative != stepsNegative)
1410 absValue /= 1.01;
1411
1412 const double shift = std::pow(10, 1 - std::floor(std::log10(absValue)));
1413 const double absRounded = round(absValue * shift) / shift;
1414 const double log = floorf(std::log10(absRounded)) - 1;
1415
1416 return std::max(minStep, std::pow(10, log));
1417}
1418
1421{
1422 Q_D(QSpinBox);
1423 if (event->type() == QEvent::StyleChange
1424#ifdef Q_OS_MAC
1425 || event->type() == QEvent::MacSizeChange
1426#endif
1427 )
1428 d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
1430}
1431
1433
1434#include "moc_qspinbox.cpp"
static int variantCompare(const QVariant &arg1, const QVariant &arg2)
QString stripped(const QString &text, int *pos=nullptr) const
QValidator::State cachedState
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
QString text
the spin box's text, including any prefix and suffix
bool isGroupSeparatorShown() const
StepType
\value DefaultStepType \value AdaptiveDecimalStepType
bool event(QEvent *event) override
\reimp
\inmodule QtCore
QVariant calculateAdaptiveDecimalStep(int steps) const override
QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const
void emitSignals(EmitPolicy ep, const QVariant &) override
double round(double input) const
virtual QVariant valueFromText(const QString &n) const override
virtual QString textFromValue(const QVariant &n) const override
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition qspinbox.h:82
virtual double valueFromText(const QString &text) const
This virtual function is used by the spin box whenever it needs to interpret text entered by the user...
Definition qspinbox.cpp:979
double singleStep
the step value
Definition qspinbox.h:91
~QDoubleSpinBox()
Destructor.
Definition qspinbox.cpp:635
QString suffix
the suffix of the spin box
Definition qspinbox.h:86
double maximum
the maximum value of the spin box
Definition qspinbox.h:90
int decimals
the precision of the spin box, in decimals
Definition qspinbox.h:88
void setValue(double val)
Definition qspinbox.cpp:657
QDoubleSpinBox(QWidget *parent=nullptr)
Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, a step value of 1....
Definition qspinbox.cpp:625
QString prefix
the spin box's prefix
Definition qspinbox.h:85
void setStepType(StepType stepType)
Sets the step type for the spin box to stepType, which is single step or adaptive decimal step.
Definition qspinbox.cpp:889
StepType stepType
The step type.
Definition qspinbox.h:92
double minimum
the minimum value of the spin box
Definition qspinbox.h:89
void setDecimals(int prec)
Definition qspinbox.cpp:930
void fixup(QString &str) const override
\reimp
void setSingleStep(double val)
Definition qspinbox.cpp:770
QString cleanText
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
Definition qspinbox.h:87
void setSuffix(const QString &suffix)
Definition qspinbox.cpp:727
void setMinimum(double min)
Definition qspinbox.cpp:803
void setPrefix(const QString &prefix)
Definition qspinbox.cpp:689
void setRange(double min, double max)
Convenience function to set the minimum and maximum values with a single function call.
Definition qspinbox.cpp:856
void setMaximum(double max)
Definition qspinbox.cpp:834
double value
the value of the spin box
Definition qspinbox.h:93
virtual QString textFromValue(double val) const
This virtual function is used by the spin box whenever it needs to display the given value.
Definition qspinbox.cpp:957
QValidator::State validate(QString &input, int &pos) const override
\reimp
Definition qspinbox.cpp:992
\inmodule QtCore
Definition qcoreevent.h:45
@ StyleChange
Definition qcoreevent.h:136
@ MacSizeChange
Definition qcoreevent.h:217
QString displayText
The displayed text.
Definition qlineedit.h:36
QString decimalPoint() const
Definition qlocale.cpp:2655
double toDouble(const QString &s, bool *ok=nullptr) const
Returns the double represented by the localized string s.
Definition qlocale.h:969
QString groupSeparator() const
Definition qlocale.cpp:2674
int toInt(const QString &s, bool *ok=nullptr) const
Returns the int represented by the localized string s.
Definition qlocale.h:955
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition qlocale.cpp:2052
\inmodule QtCore
Definition qsize.h:25
void emitSignals(EmitPolicy ep, const QVariant &) override
virtual QVariant valueFromText(const QString &n) const override
QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const
virtual QString textFromValue(const QVariant &n) const override
QVariant calculateAdaptiveDecimalStep(int steps) const override
The QSpinBox class provides a spin box widget.
Definition qspinbox.h:16
QValidator::State validate(QString &input, int &pos) const override
\reimp
Definition qspinbox.cpp:524
QSpinBox(QWidget *parent=nullptr)
Constructs a spin box with 0 as minimum value and 99 as maximum value, a step value of 1.
Definition qspinbox.cpp:165
int maximum
the maximum value of the spin box
Definition qspinbox.h:23
void fixup(QString &str) const override
\reimp
Definition qspinbox.cpp:537
void setValue(int val)
Definition qspinbox.cpp:192
void setSuffix(const QString &suffix)
Definition qspinbox.cpp:261
QString prefix
the spin box's prefix
Definition qspinbox.h:20
void setDisplayIntegerBase(int base)
Definition qspinbox.cpp:445
~QSpinBox()
Destructor.
Definition qspinbox.cpp:175
StepType stepType
The step type.
Definition qspinbox.h:25
void setSingleStep(int val)
Definition qspinbox.cpp:306
int minimum
the minimum value of the spin box
Definition qspinbox.h:22
void setMinimum(int min)
Definition qspinbox.cpp:335
void setStepType(StepType stepType)
Sets the step type for the spin box to stepType, which is single step or adaptive decimal step.
Definition qspinbox.cpp:409
bool event(QEvent *event) override
\reimp
QString cleanText
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
Definition qspinbox.h:21
int value
the value of the spin box
Definition qspinbox.h:26
void setRange(int min, int max)
Convenience function to set the minimum, and maximum values with a single function call.
Definition qspinbox.cpp:381
virtual int valueFromText(const QString &text) const
This virtual function is used by the spin box whenever it needs to interpret text entered by the user...
Definition qspinbox.cpp:511
QString suffix
the suffix of the spin box
Definition qspinbox.h:19
void setMaximum(int max)
Definition qspinbox.cpp:363
int displayIntegerBase
the base used to display the value of the spin box
Definition qspinbox.h:27
void setPrefix(const QString &prefix)
Definition qspinbox.cpp:223
int singleStep
the step value
Definition qspinbox.h:24
virtual QString textFromValue(int val) const
This virtual function is used by the spin box whenever it needs to display the given value.
Definition qspinbox.cpp:478
\inmodule QtCore
Definition qstringview.h:78
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition qstring.cpp:3466
@ SE_SpinBoxLayoutItem
Definition qstyle.h:297
State
This enum type defines the states in which a validated string can exist.
Definition qvalidator.h:30
\inmodule QtCore
Definition qvariant.h:65
double toDouble(bool *ok=nullptr) const
Returns the variant as a double if the variant has userType() \l QMetaType::Double,...
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
void setLayoutItemMargins(int left, int top, int right, int bottom)
QLocale locale
Definition qwidget_p.h:706
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
QPoint pos
the position of the widget within its parent widget
Definition qwidget.h:111
QLocale locale
the widget's locale
Definition qwidget.h:176
QString str
[2]
QString text
else opt state
[0]
Combined button and popup list for selecting options.
@ ImhFormattedNumbersOnly
@ ImhDigitsOnly
@ EmitIfChanged
@ NeverEmit
@ AlwaysEmit
static jboolean copy(JNIEnv *, jobject)
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
Definition qbezier.cpp:207
#define Q_UNLIKELY(x)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define DBL_DIG
#define qWarning
Definition qlogging.h:166
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLsizei const GLfloat * v
[13]
const GLfloat * m
GLuint GLuint end
GLfloat GLfloat f
GLenum type
GLboolean GLuint group
GLfloat n
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLenum GLsizei len
GLuint num
GLenum GLenum GLenum input
static constexpr QChar sep
#define QSBDEBUG
Definition qspinbox.cpp:24
#define emit
unsigned int uint
Definition qtypes.h:34
static const uint base
Definition qurlidna.cpp:20
manager head(request, this, [this](QRestReply &reply) { if(reply.isSuccess()) })
[6]