Inherited by: QDoubleSpinBox, QSpinBox, QDateTimeEdit, QDateEdit, QTimeEdit
The PySide.QtGui.QAbstractSpinBox class provides a spinbox and a line edit to display values.
The class is designed as a common super class for widgets like PySide.QtGui.QSpinBox , PySide.QtGui.QDoubleSpinBox and PySide.QtGui.QDateTimeEdit
Here are the main properties of the class:
PySide.QtGui.QAbstractSpinBox provides a virtual PySide.QtGui.QAbstractSpinBox.stepBy() function that is called whenever the user triggers a step. This function takes an integer value to signify how many steps were taken. E.g. Pressing Qt.Key_Down will trigger a call to stepBy(-1).
PySide.QtGui.QAbstractSpinBox also provide a virtual function PySide.QtGui.QAbstractSpinBox.stepEnabled() to determine whether stepping up/down is allowed at any point. This function returns a bitset of StepEnabled .
See also
PySide.QtGui.QAbstractSlider PySide.QtGui.QSpinBox PySide.QtGui.QDoubleSpinBox PySide.QtGui.QDateTimeEdit Spin Boxes Example
Parameters: | parent – PySide.QtGui.QWidget |
---|
Constructs an abstract spinbox with the given parent with default PySide.QtGui.QAbstractSpinBox.wrapping() , and PySide.QtGui.QAbstractSpinBox.alignment() properties.
Constant | Description |
---|---|
QAbstractSpinBox.StepNone | |
QAbstractSpinBox.StepUpEnabled | |
QAbstractSpinBox.StepDownEnabled |
This enum type describes the mode the spinbox will use to correct an Intermediate value if editing finishes.
Constant | Description |
---|---|
QAbstractSpinBox.CorrectToPreviousValue | The spinbox will revert to the last valid value. |
QAbstractSpinBox.CorrectToNearestValue | The spinbox will revert to the nearest valid value. |
This enum type describes the symbols that can be displayed on the buttons in a spin box.
Constant | Description |
---|---|
QAbstractSpinBox.UpDownArrows | Little arrows in the classic style. |
QAbstractSpinBox.PlusMinus | + and - symbols. |
QAbstractSpinBox.NoButtons | Don’t display buttons. |
See also
Return type: | PySide.QtCore.Qt.Alignment |
---|
This property holds the alignment of the spin box.
Possible Values are Qt.AlignLeft , Qt.AlignRight , and Qt.AlignHCenter .
By default, the alignment is Qt.AlignLeft
Attempting to set the alignment to an illegal flag combination does nothing.
See also
Qt.Alignment
Return type: | PySide.QtGui.QAbstractSpinBox.ButtonSymbols |
---|
This property holds the current button symbol mode.
The possible values can be either UpDownArrows or PlusMinus . The default is UpDownArrows .
Note that some styles might render PlusMinus and UpDownArrows identically.
See also
QAbstractSpinBox.ButtonSymbols
Clears the lineedit of all text but prefix and suffix.
Return type: | PySide.QtGui.QAbstractSpinBox.CorrectionMode |
---|
This property holds the mode to correct an Intermediate value if editing finishes.
The default mode is QAbstractSpinBox.CorrectToPreviousValue .
See also
acceptableInput() PySide.QtGui.QAbstractSpinBox.validate() PySide.QtGui.QAbstractSpinBox.fixup()
Parameters: | input – unicode |
---|
This virtual function is called by the PySide.QtGui.QAbstractSpinBox if the input is not validated to QValidator.Acceptable when Return is pressed or PySide.QtGui.QAbstractSpinBox.interpretText() is called. It will try to change the text so it is valid. Reimplemented in the various subclasses.
Return type: | PySide.QtCore.bool |
---|
This property holds whether the input satisfies the current validation.
Return type: | PySide.QtCore.bool |
---|
This property holds whether the spin box draws itself with a frame.
If enabled (the default) the spin box draws itself inside a frame, otherwise the spin box draws itself without any frame.
Parameters: | option – PySide.QtGui.QStyleOptionSpinBox |
---|
Initialize option with the values from this PySide.QtGui.QSpinBox . This method is useful for subclasses when they need a PySide.QtGui.QStyleOptionSpinBox , but don’t want to fill in all the information themselves.
See also
This function interprets the text of the spin box. If the value has changed since last interpretation it will emit signals.
Return type: | PySide.QtCore.bool |
---|
This property holds whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons..
If enabled the spin box will increase/decrease the value faster the longer you hold the button down.
Return type: | PySide.QtCore.bool |
---|
This property holds whether the spin box is read only..
In read-only mode, the user can still copy the text to the clipboard, or drag and drop the text; but cannot edit it.
The PySide.QtGui.QLineEdit in the PySide.QtGui.QAbstractSpinBox does not show a cursor in read-only mode.
See also
QLineEdit.readOnly
Return type: | PySide.QtCore.bool |
---|
This property holds whether keyboard tracking is enabled for the spinbox..
If keyboard tracking is enabled (the default), the spinbox emits the valueChanged() signal while the new value is being entered from the keyboard.
E.g. when the user enters the value 600 by typing 6, 0, and 0, the spinbox emits 3 signals with the values 6, 60, and 600 respectively.
If keyboard tracking is disabled, the spinbox doesn’t emit the valueChanged() signal while typing. It emits the signal later, when the return key is pressed, when keyboard focus is lost, or when other spinbox functionality is used, e.g. pressing an arrow key.
Return type: | PySide.QtGui.QLineEdit |
---|
This function returns a pointer to the line edit of the spin box.
Selects all the text in the spinbox except the prefix and suffix.
Parameters: | on – PySide.QtCore.bool |
---|
This property holds whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons..
If enabled the spin box will increase/decrease the value faster the longer you hold the button down.
Parameters: | flag – PySide.QtCore.Qt.Alignment |
---|
This property holds the alignment of the spin box.
Possible Values are Qt.AlignLeft , Qt.AlignRight , and Qt.AlignHCenter .
By default, the alignment is Qt.AlignLeft
Attempting to set the alignment to an illegal flag combination does nothing.
See also
Qt.Alignment
Parameters: | bs – PySide.QtGui.QAbstractSpinBox.ButtonSymbols |
---|
This property holds the current button symbol mode.
The possible values can be either UpDownArrows or PlusMinus . The default is UpDownArrows .
Note that some styles might render PlusMinus and UpDownArrows identically.
See also
QAbstractSpinBox.ButtonSymbols
Parameters: | cm – PySide.QtGui.QAbstractSpinBox.CorrectionMode |
---|
This property holds the mode to correct an Intermediate value if editing finishes.
The default mode is QAbstractSpinBox.CorrectToPreviousValue .
See also
acceptableInput() PySide.QtGui.QAbstractSpinBox.validate() PySide.QtGui.QAbstractSpinBox.fixup()
Parameters: | arg__1 – PySide.QtCore.bool |
---|
This property holds whether the spin box draws itself with a frame.
If enabled (the default) the spin box draws itself inside a frame, otherwise the spin box draws itself without any frame.
Parameters: | kt – PySide.QtCore.bool |
---|
This property holds whether keyboard tracking is enabled for the spinbox..
If keyboard tracking is enabled (the default), the spinbox emits the valueChanged() signal while the new value is being entered from the keyboard.
E.g. when the user enters the value 600 by typing 6, 0, and 0, the spinbox emits 3 signals with the values 6, 60, and 600 respectively.
If keyboard tracking is disabled, the spinbox doesn’t emit the valueChanged() signal while typing. It emits the signal later, when the return key is pressed, when keyboard focus is lost, or when other spinbox functionality is used, e.g. pressing an arrow key.
Parameters: | edit – PySide.QtGui.QLineEdit |
---|
Sets the line edit of the spinbox to be lineEdit instead of the current line edit widget. lineEdit can not be 0.
PySide.QtGui.QAbstractSpinBox takes ownership of the new lineEdit
If QLineEdit.validator() for the lineEdit returns 0, the internal validator of the spinbox will be set on the line edit.
Parameters: | r – PySide.QtCore.bool |
---|
This property holds whether the spin box is read only..
In read-only mode, the user can still copy the text to the clipboard, or drag and drop the text; but cannot edit it.
The PySide.QtGui.QLineEdit in the PySide.QtGui.QAbstractSpinBox does not show a cursor in read-only mode.
See also
QLineEdit.readOnly
Parameters: | txt – unicode |
---|
This property holds the special-value text.
If set, the spin box will display this text instead of a numeric value whenever the current value is equal to minimum(). Typical use is to indicate that this choice has a special (default) meaning.
For example, if your spin box allows the user to choose a scale factor (or zoom level) for displaying an image, and your application is able to automatically choose one that will enable the image to fit completely within the display window, you can set up the spin box like this:
zoomSpinBox = QSpinBox()
zoomSpinBox.setRange(0, 1000)
zoomSpinBox.setSingleStep(10)
zoomSpinBox.setSuffix("%")
zoomSpinBox.setSpecialValueText(tr("Automatic"))
zoomSpinBox.setValue(100)
The user will then be able to choose a scale from 1% to 1000% or select “Auto” to leave it up to the application to choose. Your code must then interpret the spin box value of 0 as a request from the user to scale the image to fit inside the window.
All values are displayed with the prefix and suffix (if set), except for the special value, which only shows the special value text. This special text is passed in the QSpinBox.valueChanged() signal that passes a PySide.QtCore.QString .
To turn off the special-value text display, call this function with an empty string. The default is no special-value text, i.e. the numeric value is shown as usual.
If no special-value text is set, PySide.QtGui.QAbstractSpinBox.specialValueText() returns an empty string.
Parameters: | w – PySide.QtCore.bool |
---|
This property holds whether the spin box is circular..
If wrapping is true stepping up from maximum() value will take you to the minimum() value and vica versa. Wrapping only make sense if you have minimum() and maximum() values set.
spinBox = QSpinBox(self)
spinBox.setRange(0, 100)
spinBox.setWrapping(True)
spinBox.setValue(100)
spinBox.stepBy(1)
// value is 0
See also
Return type: | unicode |
---|
This property holds the special-value text.
If set, the spin box will display this text instead of a numeric value whenever the current value is equal to minimum(). Typical use is to indicate that this choice has a special (default) meaning.
For example, if your spin box allows the user to choose a scale factor (or zoom level) for displaying an image, and your application is able to automatically choose one that will enable the image to fit completely within the display window, you can set up the spin box like this:
zoomSpinBox = QSpinBox()
zoomSpinBox.setRange(0, 1000)
zoomSpinBox.setSingleStep(10)
zoomSpinBox.setSuffix("%")
zoomSpinBox.setSpecialValueText(tr("Automatic"))
zoomSpinBox.setValue(100)
The user will then be able to choose a scale from 1% to 1000% or select “Auto” to leave it up to the application to choose. Your code must then interpret the spin box value of 0 as a request from the user to scale the image to fit inside the window.
All values are displayed with the prefix and suffix (if set), except for the special value, which only shows the special value text. This special text is passed in the QSpinBox.valueChanged() signal that passes a PySide.QtCore.QString .
To turn off the special-value text display, call this function with an empty string. The default is no special-value text, i.e. the numeric value is shown as usual.
If no special-value text is set, PySide.QtGui.QAbstractSpinBox.specialValueText() returns an empty string.
Parameters: | steps – PySide.QtCore.int |
---|
Virtual function that is called whenever the user triggers a step. The steps parameter indicates how many steps were taken, e.g. Pressing Qt.Key_Down will trigger a call to stepBy(-1), whereas pressing Qt.Key_Prior will trigger a call to stepBy(10).
If you subclass PySide.QtGui.QAbstractSpinBox you must reimplement this function. Note that this function is called even if the resulting value will be outside the bounds of minimum and maximum. It’s this function’s job to handle these situations.
Steps down by one linestep Calling this slot is analogous to calling stepBy(-1);
Return type: | PySide.QtGui.QAbstractSpinBox.StepEnabled |
---|
Virtual function that determines whether stepping up and down is legal at any given time.
The up arrow will be painted as disabled unless ( PySide.QtGui.QAbstractSpinBox.stepEnabled() & StepUpEnabled ) != 0.
The default implementation will return ( StepUpEnabled | StepDownEnabled ) if wrapping is turned on. Else it will return StepDownEnabled if value is > minimum() or’ed with StepUpEnabled if value < maximum().
If you subclass PySide.QtGui.QAbstractSpinBox you will need to reimplement this function.
Steps up by one linestep Calling this slot is analogous to calling stepBy(1);
Return type: | unicode |
---|
This property holds the spin box’s text, including any prefix and suffix.
There is no default text.
Parameters: |
|
---|---|
Return type: | PyObject |
This virtual function is called by the PySide.QtGui.QAbstractSpinBox to determine whether input is valid. The pos parameter indicates the position in the string. Reimplemented in the various subclasses.
Return type: | PySide.QtCore.bool |
---|
This property holds whether the spin box is circular..
If wrapping is true stepping up from maximum() value will take you to the minimum() value and vica versa. Wrapping only make sense if you have minimum() and maximum() values set.
spinBox = QSpinBox(self)
spinBox.setRange(0, 100)
spinBox.setWrapping(True)
spinBox.setValue(100)
spinBox.stepBy(1)
// value is 0
See also