|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QAbstractSpinBox
public class QAbstractSpinBox
The QAbstractSpinBox class provides a spinbox and a line edit to display values. The class is designed as a common super class for widgets like QSpinBox
, QDoubleSpinBox
and QDateTimeEdit
Here are the main properties of the class:
text
: The text that is displayed in the QAbstractSpinBox.alignment
: The alignment of the text in the QAbstractSpinBox.wrapping
: Whether the QAbstractSpinBox wraps from the minimum value to the maximum value and vica versa.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). QAbstractSpinBox also provide a virtual function stepEnabled()
to determine whether stepping up/down is allowed at any point. This function returns a bitset of StepEnabled.
QAbstractSlider
, QSpinBox
, QDoubleSpinBox
, QDateTimeEdit
, and Spin Boxes Example.
Nested Class Summary | |
---|---|
static class |
QAbstractSpinBox.ButtonSymbols
This enum type describes the symbols that can be displayed on the buttons in a spin box. |
static class |
QAbstractSpinBox.CorrectionMode
This enum type describes the mode the spinbox will use to correct an Intermediate value if editing finishes. |
static class |
QAbstractSpinBox.StepEnabled
|
static class |
QAbstractSpinBox.StepEnabledFlag
|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal0 |
editingFinished
This signal is emitted editing is finished. |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QAbstractSpinBox()
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties. |
|
QAbstractSpinBox(QWidget parent)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties. |
Method Summary | |
---|---|
Qt.Alignment |
alignment()
This property holds the alignment of the spin box. |
QAbstractSpinBox.ButtonSymbols |
buttonSymbols()
This property holds the current button symbol mode. |
void |
clear()
Clears the lineedit of all text but prefix and suffix. |
QAbstractSpinBox.CorrectionMode |
correctionMode()
This property holds the mode to correct an Intermediate value if editing finishes. |
java.lang.String |
fixup(java.lang.String input)
This virtual function is called by the QAbstractSpinBox if the input is not validated to QValidator::Acceptable when Return is pressed or interpretText() is called. |
boolean |
hasAcceptableInput()
This property holds whether the input satisfies the current validation. |
boolean |
hasFrame()
This property holds whether the spin box draws itself with a frame. |
protected void |
initStyleOption(QStyleOptionSpinBox option)
Initialize option with the values from this QSpinBox. |
void |
interpretText()
This function interprets the text of the spin box. |
boolean |
isAccelerated()
This property holds whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons. |
boolean |
isReadOnly()
This property holds whether the spin box is read only. |
boolean |
keyboardTracking()
This property holds whether keyboard tracking is enabled for the spinbox. |
protected QLineEdit |
lineEdit()
This function returns a pointer to the line edit of the spin box. |
void |
selectAll()
Selects all the text in the spinbox except the prefix and suffix. |
void |
setAccelerated(boolean on)
This property holds whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons. |
void |
setAlignment(Qt.Alignment flag)
This property holds the alignment of the spin box. |
void |
setAlignment(Qt.AlignmentFlag[] flag)
|
void |
setButtonSymbols(QAbstractSpinBox.ButtonSymbols bs)
This property holds the current button symbol mode. |
void |
setCorrectionMode(QAbstractSpinBox.CorrectionMode cm)
This property holds the mode to correct an Intermediate value if editing finishes. |
void |
setFrame(boolean arg__1)
This property holds whether the spin box draws itself with a frame. |
void |
setKeyboardTracking(boolean kt)
This property holds whether keyboard tracking is enabled for the spinbox. |
protected void |
setLineEdit(QLineEdit edit)
Sets the line edit of the spinbox to be lineEdit instead of the current line edit widget. |
void |
setReadOnly(boolean r)
This property holds whether the spin box is read only. |
void |
setSpecialValueText(java.lang.String txt)
This property holds the special-value text. |
void |
setWrapping(boolean w)
This property holds whether the spin box is circular. |
java.lang.String |
specialValueText()
This property holds the special-value text. |
void |
stepBy(int steps)
Virtual function that is called whenever the user triggers a step. |
void |
stepDown()
Steps down by one linestep Calling this slot is analogous to calling stepBy(-1); |
protected QAbstractSpinBox.StepEnabled |
stepEnabled()
Virtual function that determines whether stepping up and down is legal at any given time. |
void |
stepUp()
Steps up by one linestep Calling this slot is analogous to calling stepBy(1); |
java.lang.String |
text()
This property holds the spin box's text, including any prefix and suffix. |
QValidator.State |
validate(QValidator.QValidationData input)
This virtual function is called by the QAbstractSpinBox to determine whether input is valid. |
boolean |
wrapping()
This property holds whether the spin box is circular. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal0 editingFinished
Constructor Detail |
---|
public QAbstractSpinBox()
wrapping
, and alignment
properties.
public QAbstractSpinBox(QWidget parent)
wrapping
, and alignment
properties.
Method Detail |
---|
public final Qt.Alignment alignment()
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.
public final QAbstractSpinBox.ButtonSymbols buttonSymbols()
Note that some styles might render PlusMinus
and UpDownArrows
identically.
ButtonSymbols
.
public final QAbstractSpinBox.CorrectionMode correctionMode()
Intermediate
value if editing finishes. The default mode is QAbstractSpinBox::CorrectToPreviousValue
. acceptableInput
, validate()
, and fixup()
.
public final boolean hasAcceptableInput()
validate()
, fixup()
, and correctionMode
.
public final boolean hasFrame()
public final void interpretText()
public final boolean isAccelerated()
public final boolean isReadOnly()
The QLineEdit
in the QAbstractSpinBox does not show a cursor in read-only mode.
QLineEdit::readOnly
.
public final boolean keyboardTracking()
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.
protected final QLineEdit lineEdit()
setLineEdit()
.
public final void selectAll()
public final void setAccelerated(boolean on)
public final void setAlignment(Qt.AlignmentFlag[] flag)
public final void setAlignment(Qt.Alignment flag)
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.
public final void setButtonSymbols(QAbstractSpinBox.ButtonSymbols bs)
Note that some styles might render PlusMinus
and UpDownArrows
identically.
ButtonSymbols
.
public final void setCorrectionMode(QAbstractSpinBox.CorrectionMode cm)
Intermediate
value if editing finishes. The default mode is QAbstractSpinBox::CorrectToPreviousValue
. acceptableInput
, validate()
, and fixup()
.
public final void setFrame(boolean arg__1)
public final void setKeyboardTracking(boolean kt)
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.
protected final void setLineEdit(QLineEdit edit)
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.
lineEdit()
.
public final void setReadOnly(boolean r)
The QLineEdit
in the QAbstractSpinBox does not show a cursor in read-only mode.
QLineEdit::readOnly
.
public final void setSpecialValueText(java.lang.String txt)
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:
The following code example is written in c++.
QSpinBox *zoomSpinBox = new 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 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, specialValueText()
returns an empty string.
public final void setWrapping(boolean w)
QSpinBox spinBox = new QSpinBox(this); spinBox.setRange(0, 100); spinBox.setWrapping(true); spinBox.setValue(100); spinBox.stepBy(1); // value is 0
QSpinBox::minimum()
, and QSpinBox::maximum()
.
public final java.lang.String specialValueText()
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:
The following code example is written in c++.
QSpinBox *zoomSpinBox = new 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 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, specialValueText()
returns an empty string.
public final void stepDown()
stepBy()
, and stepUp()
.
public final void stepUp()
stepBy()
, and stepDown()
.
public final java.lang.String text()
public final boolean wrapping()
QSpinBox spinBox = new QSpinBox(this); spinBox.setRange(0, 100); spinBox.setWrapping(true); spinBox.setValue(100); spinBox.stepBy(1); // value is 0
QSpinBox::minimum()
, and QSpinBox::maximum()
.
public void clear()
public java.lang.String fixup(java.lang.String input)
QValidator::Acceptable
when Return is pressed or interpretText()
is called. It will try to change the text so it is valid. Reimplemented in the various subclasses.
public void stepBy(int steps)
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 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.
protected QAbstractSpinBox.StepEnabled stepEnabled()
The up arrow will be painted as disabled unless (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 QAbstractSpinBox you will need to reimplement this function.
QSpinBox::minimum()
, QSpinBox::maximum()
, and wrapping()
.
public QValidator.State validate(QValidator.QValidationData input)
protected void initStyleOption(QStyleOptionSpinBox option)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |