4#include <private/qabstractspinbox_p.h>
21#ifdef QSPINBOX_QSBDEBUG
22# define QSBDEBUG qDebug
24# define QSBDEBUG if (false) qDebug
189 return d->value.toInt();
230 d->cachedSizeHint =
QSize();
231 d->cachedMinimumSizeHint =
QSize();
268 d->cachedSizeHint =
QSize();
285 return d->stripped(
d->edit->displayText());
303 return d->singleStep.toInt();
332 return d->minimum.toInt();
360 return d->maximum.toInt();
442 return d->displayIntegerBase;
450 qWarning(
"QSpinBox::setDisplayIntegerBase: Invalid base (%d)",
base);
454 if (
base !=
d->displayIntegerBase) {
455 d->displayIntegerBase =
base;
483 if (
d->displayIntegerBase != 10) {
488 if (!
d->showGroupSeparator && (
qAbs(
value) >= 1000 ||
value == INT_MIN)) {
516 int pos =
d->edit->cursorPosition();
654 return d->value.toDouble();
696 d->cachedSizeHint =
QSize();
697 d->cachedMinimumSizeHint =
QSize();
734 d->cachedSizeHint =
QSize();
751 return d->stripped(
d->edit->displayText());
767 return d->singleStep.toDouble();
800 return d->minimum.toDouble();
831 return d->maximum.toDouble();
961 if (!
d->showGroupSeparator &&
qAbs(
value) >= 1000.0)
984 int pos =
d->edit->cursorPosition();
1024 type = QMetaType::Int;
1052 return q->textFromValue(
value.toInt());
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) {
1104 if (!
ok && (max >= 1000 || min <= -1000)) {
1107 if (
copy.contains(
sep) && !
copy.contains(doubleSep)) {
1114 QSBDEBUG() << __FILE__ << __LINE__<<
"num is set to" <<
num;
1117 }
else if (
num >= min &&
num <= max) {
1119 }
else if (max == min) {
1122 if ((
num >= 0 &&
num > max) || (
num < 0 &&
num < min)) {
1124 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1127 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Intermediate";
1132 num = max > 0 ? min : max;
1146 const int absValue =
qAbs(intValue);
1151 const bool valueNegative = intValue < 0;
1152 const bool stepsNegative = steps < 0;
1153 const int signCompensation = (valueNegative == stepsNegative) ? 0 : 1;
1155 const int log =
static_cast<int>(std::log10(absValue - signCompensation)) - 1;
1156 return static_cast<int>(std::pow(10, log));
1175 type = QMetaType::Double;
1242 const bool plus = max >= 0;
1243 const bool minus = min <= 0;
1246 const uint groupUcs = (
group.isEmpty() ? 0 :
1247 (
group.size() > 1 &&
group.at(0).isHighSurrogate()
1249 :
group.at(0).unicode()));
1256 || (plus &&
copy.at(0) == u
'+')
1257 || (minus &&
copy.at(0) == u
'-')) {
1264 && ((plus &&
copy.at(0) == u
'+') || (minus &&
copy.at(0) == u
'-'))) {
1272 if (groupUcs &&
copy.startsWith(
group)) {
1273 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1276 }
else if (
len > 1) {
1284 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1288 for (
int i =
dec + 1;
i <
copy.size(); ++
i) {
1289 if (
copy.at(
i).isSpace()
1291 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1298 const bool groupEnd = groupUcs &&
copy.endsWith(
group);
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";
1308 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1321 if (max < 1000 && min > -1000 && groupUcs &&
copy.contains(
group)) {
1323 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1328 for (
int i = 0;
i <
len - 1;) {
1331 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1349 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
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) {
1363 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1365 if ((
num >= 0 &&
num > max) || (
num < 0 &&
num < min)) {
1367 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Invalid";
1370 QSBDEBUG() << __FILE__ << __LINE__<<
"state is set to Intermediate";
1377 num = max > 0 ? min : max;
1395 return q->textFromValue(
f.toDouble());
1401 const double minStep = std::pow(10, -
decimals);
1402 double absValue =
qAbs(doubleValue);
1404 if (absValue < minStep)
1407 const bool valueNegative = doubleValue < 0;
1408 const bool stepsNegative = steps < 0;
1409 if (valueNegative != stepsNegative)
1412 const double shift = std::pow(10, 1 - std::floor(std::log10(absValue)));
1414 const double log = floorf(std::log10(absRounded)) - 1;
1416 return std::max(minStep, std::pow(10, log));
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
static constexpr char32_t surrogateToUcs4(char16_t high, char16_t low) noexcept
Converts a UTF16 surrogate pair with the given high and low values to it's UCS-4-encoded code point.
bool isPrint() const noexcept
Returns true if the character is a printable character; otherwise returns false.
constexpr bool isSpace() const noexcept
Returns true if the character is a separator character (Separator_* categories or certain code points...
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.
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...
double singleStep
the step value
~QDoubleSpinBox()
Destructor.
QString suffix
the suffix of the spin box
double maximum
the maximum value of the spin box
int decimals
the precision of the spin box, in decimals
void setValue(double val)
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....
QString prefix
the spin box's prefix
void setStepType(StepType stepType)
Sets the step type for the spin box to stepType, which is single step or adaptive decimal step.
StepType stepType
The step type.
double minimum
the minimum value of the spin box
void setDecimals(int prec)
void fixup(QString &str) const override
\reimp
void setSingleStep(double val)
QString cleanText
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
void setSuffix(const QString &suffix)
void setMinimum(double min)
void setPrefix(const QString &prefix)
void setRange(double min, double max)
Convenience function to set the minimum and maximum values with a single function call.
void setMaximum(double max)
double value
the value of the spin box
virtual QString textFromValue(double val) const
This virtual function is used by the spin box whenever it needs to display the given value.
QValidator::State validate(QString &input, int &pos) const override
\reimp
QString displayText
the displayed text.
QString decimalPoint() const
double toDouble(const QString &s, bool *ok=nullptr) const
Returns the double represented by the localized string s.
QString groupSeparator() const
int toInt(const QString &s, bool *ok=nullptr) const
Returns the int represented by the localized string s.
QString toString(qlonglong i) const
Returns a localized string representation of i.
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.
QValidator::State validate(QString &input, int &pos) const override
\reimp
QSpinBox(QWidget *parent=nullptr)
Constructs a spin box with 0 as minimum value and 99 as maximum value, a step value of 1.
int maximum
the maximum value of the spin box
void fixup(QString &str) const override
\reimp
void setSuffix(const QString &suffix)
QString prefix
the spin box's prefix
void setDisplayIntegerBase(int base)
StepType stepType
The step type.
void setSingleStep(int val)
int minimum
the minimum value of the spin box
void setStepType(StepType stepType)
Sets the step type for the spin box to stepType, which is single step or adaptive decimal step.
bool event(QEvent *event) override
\reimp
QString cleanText
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
int value
the value of the spin box
void setRange(int min, int max)
Convenience function to set the minimum, and maximum values with a single function call.
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...
QString suffix
the suffix of the spin box
int displayIntegerBase
the base used to display the value of the spin box
void setPrefix(const QString &prefix)
int singleStep
the step value
virtual QString textFromValue(int val) const
This virtual function is used by the spin box whenever it needs to display the given value.
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
double toDouble(bool *ok=nullptr) const
Returns the string converted to a double value.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
State
This enum type defines the states in which a validated string can exist.
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,...
Combined button and popup list for selecting options.
@ ImhFormattedNumbersOnly
static jboolean copy(JNIEnv *, jobject)
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr T qAbs(const T &t)
GLsizei const GLfloat * v
[13]
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLenum input
static constexpr QChar sep
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent