QtBase
v6.3.1
|
The QSpinBox class provides a spin box widget. More...
#include <qspinbox.h>
Public Slots | |
void | setValue (int val) |
Public Slots inherited from QAbstractSpinBox | |
void | stepUp () |
void | stepDown () |
void | selectAll () |
virtual void | clear () |
Public Slots inherited from QWidget | |
void | setEnabled (bool) |
void | setDisabled (bool) |
void | setWindowModified (bool) |
void | setWindowTitle (const QString &) |
void | setStyleSheet (const QString &styleSheet) |
void | setFocus () |
void | update () |
void | repaint () |
virtual void | setVisible (bool visible) |
void | setHidden (bool hidden) |
void | show () |
void | hide () |
void | showMinimized () |
void | showMaximized () |
void | showFullScreen () |
void | showNormal () |
bool | close () |
void | raise () |
void | lower () |
Public Slots inherited from QObject | |
void | deleteLater () |
Signals | |
void | valueChanged (int) |
void | textChanged (const QString &) |
Signals inherited from QAbstractSpinBox | |
void | editingFinished () |
Signals inherited from QWidget | |
void | windowTitleChanged (const QString &title) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | customContextMenuRequested (const QPoint &pos) |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
Properties | |
QString | suffix |
the suffix of the spin box More... | |
QString | prefix |
the spin box's prefix More... | |
QString | cleanText |
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace. More... | |
int | minimum |
the minimum value of the spin box More... | |
int | maximum |
the maximum value of the spin box More... | |
int | singleStep |
the step value More... | |
StepType | stepType |
The step type. More... | |
int | value |
the value of the spin box More... | |
int | displayIntegerBase |
the base used to display the value of the spin box More... | |
Properties inherited from QAbstractSpinBox | |
bool | wrapping |
whether the spin box is circular. More... | |
bool | frame |
whether the spin box draws itself with a frame More... | |
Qt::Alignment | alignment |
the alignment of the spin box More... | |
bool | readOnly |
whether the spin box is read only. More... | |
ButtonSymbols | buttonSymbols |
the current button symbol mode More... | |
QString | specialValueText |
the special-value text More... | |
QString | text |
the spin box's text, including any prefix and suffix More... | |
bool | accelerated |
whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons. More... | |
CorrectionMode | correctionMode |
the mode to correct an \l{QValidator::}{Intermediate} value if editing finishes More... | |
bool | acceptableInput |
whether the input satisfies the current validation More... | |
bool | keyboardTracking |
whether keyboard tracking is enabled for the spinbox. More... | |
bool | showGroupSeparator |
whether a thousands separator is enabled. By default this property is false. More... | |
Properties inherited from QWidget | |
bool | modal |
whether the widget is a modal widget More... | |
Qt::WindowModality | windowModality |
which windows are blocked by the modal widget More... | |
bool | enabled |
whether the widget is enabled More... | |
QRect | geometry |
the geometry of the widget relative to its parent and excluding the window frame More... | |
QRect | frameGeometry |
geometry of the widget relative to its parent including any window frame More... | |
QRect | normalGeometry |
the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More... | |
int | x |
the x coordinate of the widget relative to its parent including any window frame More... | |
int | y |
the y coordinate of the widget relative to its parent and including any window frame More... | |
QPoint | pos |
the position of the widget within its parent widget More... | |
QSize | frameSize |
the size of the widget including any window frame More... | |
QSize | size |
the size of the widget excluding any window frame More... | |
int | width |
the width of the widget excluding any window frame More... | |
int | height |
the height of the widget excluding any window frame More... | |
QRect | rect |
the internal geometry of the widget excluding any window frame More... | |
QRect | childrenRect |
the bounding rectangle of the widget's children More... | |
QRegion | childrenRegion |
the combined region occupied by the widget's children More... | |
QSizePolicy | sizePolicy |
the default layout behavior of the widget More... | |
QSize | minimumSize |
the widget's minimum size More... | |
QSize | maximumSize |
the widget's maximum size in pixels More... | |
int | minimumWidth |
the widget's minimum width in pixels More... | |
int | minimumHeight |
the widget's minimum height in pixels More... | |
int | maximumWidth |
the widget's maximum width in pixels More... | |
int | maximumHeight |
the widget's maximum height in pixels More... | |
QSize | sizeIncrement |
the size increment of the widget More... | |
QSize | baseSize |
the base size of the widget More... | |
QPalette | palette |
the widget's palette More... | |
QFont | font |
the font currently set for the widget More... | |
QCursor | cursor |
the cursor shape for this widget More... | |
bool | mouseTracking |
whether mouse tracking is enabled for the widget More... | |
bool | tabletTracking |
whether tablet tracking is enabled for the widget More... | |
bool | isActiveWindow |
whether this widget's window is the active window More... | |
Qt::FocusPolicy | focusPolicy |
the way the widget accepts keyboard focus More... | |
bool | focus |
whether this widget (or its focus proxy) has the keyboard input focus More... | |
Qt::ContextMenuPolicy | contextMenuPolicy |
how the widget shows a context menu More... | |
bool | updatesEnabled |
whether updates are enabled More... | |
bool | visible |
whether the widget is visible More... | |
bool | minimized |
whether this widget is minimized (iconified) More... | |
bool | maximized |
whether this widget is maximized More... | |
bool | fullScreen |
whether the widget is shown in full screen mode More... | |
QSize | sizeHint |
the recommended size for the widget More... | |
QSize | minimumSizeHint |
the recommended minimum size for the widget More... | |
bool | acceptDrops |
whether drop events are enabled for this widget More... | |
QString | windowTitle |
the window title (caption) More... | |
QIcon | windowIcon |
the widget's icon More... | |
QString | windowIconText |
the text to be displayed on the icon of a minimized window More... | |
double | windowOpacity |
The level of opacity for the window. More... | |
bool | windowModified |
whether the document shown in the window has unsaved changes More... | |
QString | accessibleName |
the widget's name as seen by assistive technologies More... | |
QString | accessibleDescription |
the widget's description as seen by assistive technologies More... | |
Qt::LayoutDirection | layoutDirection |
the layout direction for this widget. More... | |
bool | autoFillBackground |
whether the widget background is filled automatically More... | |
QString | styleSheet |
the widget's style sheet More... | |
QLocale | locale |
the widget's locale More... | |
QString | windowFilePath |
the file path associated with a widget More... | |
Qt::InputMethodHints | inputMethodHints |
What input method specific hints the widget has. More... | |
Properties inherited from QObject | |
QString | objectName |
the name of this object More... | |
The QSpinBox class provides a spin box widget.
\inmodule QtWidgets
QSpinBox is designed to handle integers and discrete sets of values (e.g., month names); use QDoubleSpinBox for floating point values.
QSpinBox allows the user to choose a value by clicking the up/down buttons or pressing up/down on the keyboard to increase/decrease the value currently displayed. The user can also type the value in manually. The spin box supports integer values but can be extended to use different strings with validate(), textFromValue() and valueFromText().
Every time the value changes QSpinBox emits valueChanged() and textChanged() signals, the former providing a int and the latter a QString. The textChanged() signal provides the value with both prefix() and suffix(). The current value can be fetched with value() and set with setValue().
Clicking the up/down buttons or using the keyboard accelerator's up and down arrows will increase or decrease the current value in steps of size singleStep(). If you want to change this behaviour you can reimplement the virtual function stepBy(). The minimum and maximum value and the step size can be set using one of the constructors, and can be changed later with setMinimum(), setMaximum() and setSingleStep().
Most spin boxes are directional, but QSpinBox can also operate as a circular spin box, i.e. if the range is 0-99 and the current value is 99, clicking "up" will give 0 if wrapping() is set to true. Use setWrapping() if you want circular behavior.
The displayed value can be prepended and appended with arbitrary strings indicating, for example, currency or the unit of measurement. See setPrefix() and setSuffix(). The text in the spin box is retrieved with text() (which includes any prefix() and suffix()), or with cleanText() (which has no prefix(), no suffix() and no leading or trailing whitespace).
It is often desirable to give the user a special (often default) choice in addition to the range of numeric values. See setSpecialValueText() for how to do this with QSpinBox.
Definition at line 51 of file qspinbox.h.
Constructs a spin box with 0 as minimum value and 99 as maximum value, a step value of 1. The value is initially set to 0. It is parented to parent.
Definition at line 202 of file qspinbox.cpp.
QSpinBox::~QSpinBox | ( | ) |
Destructor.
Definition at line 212 of file qspinbox.cpp.
QString QSpinBox::cleanText | ( | ) | const |
Definition at line 318 of file qspinbox.cpp.
int QSpinBox::displayIntegerBase | ( | ) | const |
Definition at line 476 of file qspinbox.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 1458 of file qspinbox.cpp.
\reimp
Reimplemented from QAbstractSpinBox.
Definition at line 574 of file qspinbox.cpp.
int QSpinBox::maximum | ( | ) | const |
Definition at line 393 of file qspinbox.cpp.
int QSpinBox::minimum | ( | ) | const |
Definition at line 365 of file qspinbox.cpp.
QString QSpinBox::prefix | ( | ) | const |
Definition at line 254 of file qspinbox.cpp.
void QSpinBox::setDisplayIntegerBase | ( | int | base | ) |
Definition at line 482 of file qspinbox.cpp.
void QSpinBox::setMaximum | ( | int | max | ) |
Definition at line 400 of file qspinbox.cpp.
void QSpinBox::setMinimum | ( | int | min | ) |
Definition at line 372 of file qspinbox.cpp.
Definition at line 260 of file qspinbox.cpp.
void QSpinBox::setRange | ( | int | minimum, |
int | maximum | ||
) |
Convenience function to set the minimum, and maximum values with a single function call.
is equivalent to:
Definition at line 418 of file qspinbox.cpp.
void QSpinBox::setSingleStep | ( | int | val | ) |
void QSpinBox::setStepType | ( | QAbstractSpinBox::StepType | stepType | ) |
Sets the step type for the spin box to stepType, which is single step or adaptive decimal step.
Adaptive decimal step means that the step size will continuously be adjusted to one power of ten below the current \l value. So when the value is 1100, the step is set to 100, so stepping up once increases it to 1200. For 1200 stepping up takes it to 1300. For negative values, stepping down from -1100 goes to -1200.
Step direction is taken into account to handle edges cases, so that stepping down from 100 takes the value to 99 instead of 90. Thus a step up followed by a step down – or vice versa – always lands on the starting value; 99 -> 100 -> 99.
Setting this will cause the spin box to disregard the value of \l singleStep, although it is preserved so that \l singleStep comes into effect if adaptive decimal step is later turned off.
Definition at line 446 of file qspinbox.cpp.
Definition at line 298 of file qspinbox.cpp.
|
slot |
int QSpinBox::singleStep | ( | ) | const |
Definition at line 336 of file qspinbox.cpp.
QAbstractSpinBox::StepType QSpinBox::stepType | ( | ) | const |
Definition at line 459 of file qspinbox.cpp.
QString QSpinBox::suffix | ( | ) | const |
Definition at line 291 of file qspinbox.cpp.
|
protectedvirtual |
This virtual function is used by the spin box whenever it needs to display the given value. The default implementation returns a string containing value printed in the standard way using QWidget::locale().toString(), but with the thousand separator removed unless setGroupSeparatorShown() is set. Reimplementations may return anything. (See the example in the detailed description.)
Note: QSpinBox does not call this function for specialValueText() and that neither prefix() nor suffix() should be included in the return value.
If you reimplement this, you may also need to reimplement valueFromText() and validate()
Reimplemented in IconSizeSpinBox, and SpinBox.
Definition at line 515 of file qspinbox.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractSpinBox.
Reimplemented in SpinBox.
Definition at line 561 of file qspinbox.cpp.
int QSpinBox::value | ( | ) | const |
|
signal |
This signal is emitted whenever the spin box's value is changed. The new value's integer value is passed in i.
This virtual function is used by the spin box whenever it needs to interpret text entered by the user as a value.
Subclasses that need to display spin box values in a non-numeric way need to reimplement this function.
Note: QSpinBox handles specialValueText() separately; this function is only concerned with the other values.
Reimplemented in SpinBox, and IconSizeSpinBox.
Definition at line 548 of file qspinbox.cpp.
|
read |
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the base used to display the value of the spin box
The default displayIntegerBase value is 10.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the maximum value of the spin box
When setting this property the minimum is adjusted if necessary, to ensure that the range remains valid.
The default maximum value is 99.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the minimum value of the spin box
When setting this property the \l maximum is adjusted if necessary to ensure that the range remains valid.
The default minimum value is 0.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the spin box's prefix
The prefix is prepended to the start of the displayed value. Typical use is to display a unit of measurement or a currency symbol. For example:
To turn off the prefix display, set this property to an empty string. The default is no prefix. The prefix is not displayed when value() == minimum() and specialValueText() is set.
If no prefix is set, prefix() returns an empty string.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the step value
When the user uses the arrows to change the spin box's value the value will be incremented/decremented by the amount of the singleStep. The default value is 1. Setting a singleStep value of less than 0 does nothing.
Definition at line 178 of file qspinbox.h.
|
readwrite |
The step type.
The step type can be single step or adaptive decimal step.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the suffix of the spin box
The suffix is appended to the end of the displayed value. Typical use is to display a unit of measurement or a currency symbol. For example:
To turn off the suffix display, set this property to an empty string. The default is no suffix. The suffix is not displayed for the minimum() if specialValueText() is set.
If no suffix is set, suffix() returns an empty string.
Definition at line 178 of file qspinbox.h.
|
readwrite |
the value of the spin box
setValue() will emit valueChanged() if the new value is different from the old one. The value property has a second notifier signal which includes the spin box's prefix and suffix.
Definition at line 178 of file qspinbox.h.