#include <qabstractspinbox.h>
Inheritance diagram for QAbstractSpinBox:


The class is designed as a common super class for widgets like QSpinBox, QDoubleSpinBox and QDateTimeEdit
Here are the main properties of the class:
1
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.
QAbstractSpinBox provides a virtual 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.
Definition at line 40 of file qabstractspinbox.h.
StepNone StepUpEnabled StepDownEnabled
Definition at line 61 of file qabstractspinbox.h.
00061 { StepNone = 0x00, StepUpEnabled = 0x01, 00062 StepDownEnabled = 0x02 };
This enum type describes the symbols that can be displayed on the buttons in a spin box.
qspinbox-updown.png qspinbox-plusminus.png
UpDownArrows Little arrows in the classic style. PlusMinus {+} and {-} symbols.
Definition at line 65 of file qabstractspinbox.h.
00065 { UpDownArrows, PlusMinus };
This enum type describes the mode the spinbox will use to correct an {QValidator::}{Intermediate} value if editing finishes.
CorrectToPreviousValue The spinbox will revert to the last valid value.
CorrectToNearestValue The spinbox will revert to the nearest valid value.
Definition at line 70 of file qabstractspinbox.h.
00070 { CorrectToPreviousValue, CorrectToNearestValue };
| QAbstractSpinBox::QAbstractSpinBox | ( | QWidget * | parent = 0 |
) | [explicit] |
Constructs an abstract spinbox with the given parent with default wrapping, and alignment properties.
Definition at line 110 of file qabstractspinbox.cpp.
References d.
00111 : QWidget(*new QAbstractSpinBoxPrivate, parent, 0) 00112 { 00113 Q_D(QAbstractSpinBox); 00114 d->init(); 00115 }
| QAbstractSpinBox::~QAbstractSpinBox | ( | ) |
| QAbstractSpinBox::QAbstractSpinBox | ( | QAbstractSpinBoxPrivate & | dd, | |
| QWidget * | parent = 0 | |||
| ) | [protected] |
Definition at line 120 of file qabstractspinbox.cpp.
References d.
00121 : QWidget(dd, parent, 0) 00122 { 00123 Q_D(QAbstractSpinBox); 00124 d->init(); 00125 }
| QAbstractSpinBox::ButtonSymbols QAbstractSpinBox::buttonSymbols | ( | ) | const |
Definition at line 161 of file qabstractspinbox.cpp.
References d.
00162 { 00163 Q_D(const QAbstractSpinBox); 00164 return d->buttonSymbols; 00165 }
| void QAbstractSpinBox::setButtonSymbols | ( | ButtonSymbols | bs | ) |
Definition at line 167 of file qabstractspinbox.cpp.
References d, and QWidget::update().
00168 { 00169 Q_D(QAbstractSpinBox); 00170 if (d->buttonSymbols != buttonSymbols) { 00171 d->buttonSymbols = buttonSymbols; 00172 update(); 00173 } 00174 }
| void QAbstractSpinBox::setCorrectionMode | ( | CorrectionMode | cm | ) |
Definition at line 372 of file qabstractspinbox.cpp.
References d.
00373 { 00374 Q_D(QAbstractSpinBox); 00375 d->correctionMode = correctionMode; 00376 00377 }
| QAbstractSpinBox::CorrectionMode QAbstractSpinBox::correctionMode | ( | ) | const |
Definition at line 378 of file qabstractspinbox.cpp.
References d.
00379 { 00380 Q_D(const QAbstractSpinBox); 00381 return d->correctionMode; 00382 }
| bool QAbstractSpinBox::hasAcceptableInput | ( | ) | const |
Definition at line 393 of file qabstractspinbox.cpp.
References d.
00394 { 00395 Q_D(const QAbstractSpinBox); 00396 return d->edit->hasAcceptableInput(); 00397 }
| QString QAbstractSpinBox::text | ( | ) | const |
Definition at line 184 of file qabstractspinbox.cpp.
References QLineEdit::displayText(), and lineEdit().
Referenced by QCalendarWidgetPrivate::_q_yearEditingFinished(), QDateTimeEdit::dateTimeFromText(), keyPressEvent(), QAccessibleSpinBox::text(), QSpinBox::validate(), QDoubleSpinBox::validate(), QDateTimeEdit::validate(), IconSizeSpinBox::valueFromText(), QSpinBox::valueFromText(), and QDoubleSpinBox::valueFromText().
00185 { 00186 return lineEdit()->displayText(); 00187 }
Here is the call graph for this function:

| QString QAbstractSpinBox::specialValueText | ( | ) | const |
Definition at line 225 of file qabstractspinbox.cpp.
References d.
Referenced by setSpecialValueText().
00226 { 00227 Q_D(const QAbstractSpinBox); 00228 return d->specialValueText; 00229 }
| void QAbstractSpinBox::setSpecialValueText | ( | const QString & | txt | ) |
Definition at line 231 of file qabstractspinbox.cpp.
References d, and specialValueText().
Referenced by Window::createDoubleSpinBoxes(), qdesigner_internal::IntProperty::createEditor(), qdesigner_internal::SpinBoxDoubleProperty::createEditor(), Window::createSpinBoxes(), and QueryPage::QueryPage().
00232 { 00233 Q_D(QAbstractSpinBox); 00234 00235 d->specialValueText = specialValueText; 00236 d->clearCache(); 00237 d->updateEdit(); 00238 }
Here is the call graph for this function:

| bool QAbstractSpinBox::wrapping | ( | ) | const |
Definition at line 261 of file qabstractspinbox.cpp.
References d.
00262 { 00263 Q_D(const QAbstractSpinBox); 00264 return d->wrapping; 00265 }
| void QAbstractSpinBox::setWrapping | ( | bool | w | ) |
Definition at line 267 of file qabstractspinbox.cpp.
References d.
00268 { 00269 Q_D(QAbstractSpinBox); 00270 d->wrapping = wrapping; 00271 }
| void QAbstractSpinBox::setReadOnly | ( | bool | r | ) |
Definition at line 294 of file qabstractspinbox.cpp.
References d, and QWidget::update().
00295 { 00296 Q_D(QAbstractSpinBox); 00297 d->readOnly = enable; 00298 d->edit->setReadOnly(enable); 00299 update(); 00300 }
| bool QAbstractSpinBox::isReadOnly | ( | ) | const |
Definition at line 288 of file qabstractspinbox.cpp.
References d.
Referenced by keyPressEvent().
00289 { 00290 Q_D(const QAbstractSpinBox); 00291 return d->readOnly; 00292 }
| void QAbstractSpinBox::setAlignment | ( | Qt::Alignment | flag | ) |
Definition at line 420 of file qabstractspinbox.cpp.
References d.
00421 { 00422 Q_D(QAbstractSpinBox); 00423 00424 d->edit->setAlignment(flag); 00425 }
| Qt::Alignment QAbstractSpinBox::alignment | ( | ) | const |
Definition at line 413 of file qabstractspinbox.cpp.
References d.
00414 { 00415 Q_D(const QAbstractSpinBox); 00416 00417 return (Qt::Alignment)d->edit->alignment(); 00418 }
| void QAbstractSpinBox::setFrame | ( | bool | ) |
Definition at line 317 of file qabstractspinbox.cpp.
References d, and QWidget::update().
Referenced by qdesigner_internal::IntProperty::createEditor(), BookDelegate::createEditor(), qdesigner_internal::SpinBoxDoubleProperty::createEditor(), QDefaultItemEditorFactory::createEditor(), and QCalendarWidgetPrivate::createHeader().
00318 { 00319 Q_D(QAbstractSpinBox); 00320 d->frame = enable; 00321 update(); 00322 d->updateEditFieldGeometry(); 00323 }
| bool QAbstractSpinBox::hasFrame | ( | ) | const |
Definition at line 310 of file qabstractspinbox.cpp.
References d.
00311 { 00312 Q_D(const QAbstractSpinBox); 00313 return d->frame; 00314 }
| void QAbstractSpinBox::setAccelerated | ( | bool | on | ) |
Definition at line 335 of file qabstractspinbox.cpp.
References d.
00336 { 00337 Q_D(QAbstractSpinBox); 00338 d->accelerate = accelerate; 00339 00340 }
| bool QAbstractSpinBox::isAccelerated | ( | ) | const |
Definition at line 341 of file qabstractspinbox.cpp.
References d.
00342 { 00343 Q_D(const QAbstractSpinBox); 00344 return d->accelerate; 00345 }
| QSize QAbstractSpinBox::sizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 734 of file qabstractspinbox.cpp.
References QStyle::CC_SpinBox, QStyle::CT_SpinBox, d, QWidget::ensurePolished(), QSize::expandedTo(), QWidget::fontMetrics(), QApplication::globalStrut(), h, qMax(), QStyleOption::rect, QWidget::rect(), s, QStyle::SC_SpinBoxEditField, QRect::setSize(), QRect::size(), QStyle::sizeFromContents(), QWidget::style(), QStyle::subControlRect(), w, and QFontMetrics::width().
Referenced by QCalendarWidgetPrivate::_q_yearClicked().
00735 { 00736 Q_D(const QAbstractSpinBox); 00737 ensurePolished(); 00738 00739 const QFontMetrics fm(fontMetrics()); 00740 int h = d->edit->sizeHint().height(); 00741 int w = 0; 00742 QString s; 00743 s = d->prefix + d->textFromValue(d->minimum) + d->suffix + QLatin1Char(' '); 00744 s.truncate(18); 00745 w = qMax(w, fm.width(s)); 00746 s = d->prefix + d->textFromValue(d->maximum) + d->suffix + QLatin1Char(' '); 00747 s.truncate(18); 00748 w = qMax(w, fm.width(s)); 00749 if (d->specialValueText.size()) { 00750 s = d->specialValueText; 00751 w = qMax(w, fm.width(s)); 00752 } 00753 w += 2; // cursor blinking space 00754 00755 QStyleOptionSpinBox opt = d->getStyleOption(); 00756 QSize hint(w, h); 00757 QSize extra(35, 6); 00758 opt.rect.setSize(hint + extra); 00759 extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, 00760 QStyle::SC_SpinBoxEditField, this).size(); 00761 // get closer to final result by repeating the calculation 00762 opt.rect.setSize(hint + extra); 00763 extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, 00764 QStyle::SC_SpinBoxEditField, this).size(); 00765 hint += extra; 00766 00767 opt.rect = rect(); 00768 return style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) 00769 .expandedTo(QApplication::globalStrut()); 00770 }
Here is the call graph for this function:

| QSize QAbstractSpinBox::minimumSizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 776 of file qabstractspinbox.cpp.
References QStyle::CC_SpinBox, QStyle::CT_SpinBox, d, QWidget::ensurePolished(), QSize::expandedTo(), QWidget::fontMetrics(), QApplication::globalStrut(), h, QStyleOption::rect, QWidget::rect(), QStyle::SC_SpinBoxEditField, QRect::setSize(), QRect::size(), QStyle::sizeFromContents(), QWidget::style(), QStyle::subControlRect(), w, and QFontMetrics::width().
00777 { 00778 Q_D(const QAbstractSpinBox); 00779 ensurePolished(); 00780 00781 const QFontMetrics fm(fontMetrics()); 00782 int h = d->edit->minimumSizeHint().height(); 00783 int w = fm.width(QLatin1String("1000")); 00784 w += 2; // cursor blinking space 00785 00786 QStyleOptionSpinBox opt = d->getStyleOption(); 00787 QSize hint(w, h); 00788 QSize extra(35, 6); 00789 opt.rect.setSize(hint + extra); 00790 extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, 00791 QStyle::SC_SpinBoxEditField, this).size(); 00792 // get closer to final result by repeating the calculation 00793 opt.rect.setSize(hint + extra); 00794 extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, 00795 QStyle::SC_SpinBoxEditField, this).size(); 00796 hint += extra; 00797 00798 opt.rect = rect(); 00799 00800 return style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) 00801 .expandedTo(QApplication::globalStrut()); 00802 }
Here is the call graph for this function:

| void QAbstractSpinBox::interpretText | ( | ) |
This function interprets the text of the spin box. If the value has changed since last interpretation it will emit signals.
Definition at line 638 of file qabstractspinbox.cpp.
References d, and EmitIfChanged.
Referenced by SpinBoxDelegate::setModelData().
00639 { 00640 Q_D(QAbstractSpinBox); 00641 d->interpret(EmitIfChanged); 00642 }
| bool QAbstractSpinBox::event | ( | QEvent * | event | ) | [virtual] |
Reimplemented from QWidget.
Definition at line 648 of file qabstractspinbox.cpp.
References QEvent::ApplicationLayoutDirectionChange, d, QWidget::event(), QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, QEvent::LayoutDirectionChange, and QEvent::ShortcutOverride.
Referenced by changeEvent(), closeEvent(), contextMenuEvent(), QDateTimeEdit::event(), QSpinBox::event(), focusInEvent(), focusOutEvent(), hideEvent(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), resizeEvent(), timerEvent(), and wheelEvent().
00649 { 00650 Q_D(QAbstractSpinBox); 00651 switch (event->type()) { 00652 case QEvent::ApplicationLayoutDirectionChange: 00653 case QEvent::LayoutDirectionChange: 00654 d->updateEditFieldGeometry(); 00655 break; 00656 case QEvent::HoverEnter: 00657 case QEvent::HoverLeave: 00658 case QEvent::HoverMove: 00659 if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) 00660 d->updateHoverControl(he->pos()); 00661 break; 00662 case QEvent::ShortcutOverride: 00663 if (d->edit->event(event)) 00664 return true; 00665 break; 00666 default: 00667 break; 00668 } 00669 return QWidget::event(event); 00670 }
Here is the call graph for this function:

| QValidator::State QAbstractSpinBox::validate | ( | QString & | input, | |
| int & | pos | |||
| ) | const [virtual] |
This virtual function is called by the QAbstractSpinBox to determine whether input is valid. The pos parameter indicates the position in the string. Reimplemented in the various subclasses.
Definition at line 499 of file qabstractspinbox.cpp.
References QValidator::Acceptable.
Referenced by stepBy(), and QSpinBoxValidator::validate().
00500 { 00501 return QValidator::Acceptable; 00502 }
| void QAbstractSpinBox::fixup | ( | QString & | input | ) | const [virtual] |
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. It will try to change the text so it is valid. Reimplemented in the various subclasses.
Definition at line 511 of file qabstractspinbox.cpp.
Referenced by QSpinBoxValidator::fixup().
| void QAbstractSpinBox::stepBy | ( | int | steps | ) | [virtual] |
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 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.
Definition at line 549 of file qabstractspinbox.cpp.
References QValidator::Acceptable, AlwaysEmit, d, EmitIfChanged, NeverEmit, selectAll(), and validate().
Referenced by contextMenuEvent(), keyPressEvent(), qdesigner_internal::QtSpinBox::stepBy(), QDoublePropertySpinBox::stepBy(), QIntPropertySpinBox::stepBy(), qdesigner_internal::QtDoubleSpinBox::stepBy(), stepDown(), stepUp(), timerEvent(), and wheelEvent().
00550 { 00551 Q_D(QAbstractSpinBox); 00552 00553 const QVariant old = d->value; 00554 QString tmp = d->edit->displayText(); 00555 int cursorPos = d->edit->cursorPosition(); 00556 bool dontstep = false; 00557 EmitPolicy e = EmitIfChanged; 00558 if (d->pendingEmit) { 00559 dontstep = validate(tmp, cursorPos) != QValidator::Acceptable; 00560 d->interpret(NeverEmit); 00561 if (d->value != old) 00562 e = AlwaysEmit; 00563 } 00564 if (!dontstep) { 00565 d->setValue(d->bound(d->value + (d->singleStep * steps), old, steps), e); 00566 } else if (e == AlwaysEmit) { 00567 d->emitSignals(e, old); 00568 } 00569 selectAll(); 00570 }
Here is the call graph for this function:

| void QAbstractSpinBox::stepUp | ( | ) | [slot] |
Steps up by one linestep Calling this slot is analogous to calling stepBy(1);
Definition at line 521 of file qabstractspinbox.cpp.
References stepBy().
00522 { 00523 stepBy(1); 00524 }
| void QAbstractSpinBox::stepDown | ( | ) | [slot] |
| void QAbstractSpinBox::selectAll | ( | ) | [slot] |
Selects all the text in the spinbox except the prefix and suffix.
Definition at line 431 of file qabstractspinbox.cpp.
References d.
Referenced by QCalendarWidgetPrivate::_q_yearClicked(), qdesigner_internal::IntProperty::createEditor(), qdesigner_internal::SpinBoxDoubleProperty::createEditor(), focusInEvent(), QInputDialog::getInteger(), keyPressEvent(), QDateTimeEdit::keyPressEvent(), and stepBy().
00432 { 00433 Q_D(QAbstractSpinBox); 00434 00435 00436 if (!d->specialValue()) { 00437 const int tmp = d->edit->displayText().size() - d->suffix.size(); 00438 d->edit->setSelection(tmp, -(tmp - d->prefix.size())); 00439 } else { 00440 d->edit->selectAll(); 00441 } 00442 }
| void QAbstractSpinBox::clear | ( | ) | [virtual, slot] |
Clears the lineedit of all text but prefix and suffix.
Definition at line 448 of file qabstractspinbox.cpp.
References d.
Referenced by keyPressEvent().
00449 { 00450 Q_D(QAbstractSpinBox); 00451 00452 00453 d->edit->setText(d->prefix + d->suffix); 00454 d->edit->setCursorPosition(d->prefix.size()); 00455 }
| void QAbstractSpinBox::resizeEvent | ( | QResizeEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 721 of file qabstractspinbox.cpp.
References d, event(), QWidget::resizeEvent(), and QWidget::update().
00722 { 00723 Q_D(QAbstractSpinBox); 00724 QWidget::resizeEvent(event); 00725 00726 d->updateEditFieldGeometry(); 00727 update(); 00728 }
Here is the call graph for this function:

| void QAbstractSpinBox::keyPressEvent | ( | QKeyEvent * | event | ) | [protected, virtual] |
This function handles keyboard input.
The following keys are handled specifically: Enter/Return This will reinterpret the text and emit a signal even if the value has not changed since last time a signal was emitted. Up This will invoke stepBy(1) Down This will invoke stepBy(-1) Page up This will invoke stepBy(10) Page down This will invoke stepBy(-10)
Reimplemented from QWidget.
Definition at line 839 of file qabstractspinbox.cpp.
References AlwaysEmit, clear(), Qt::ControlModifier, d, Down, editingFinished(), emit, event(), isReadOnly(), Qt::Key_A, Qt::Key_Back, Qt::Key_Down, Qt::Key_End, Qt::Key_Enter, Qt::Key_Home, Qt::Key_Left, Qt::Key_PageDown, Qt::Key_PageUp, Qt::Key_Return, Qt::Key_Right, Qt::Key_Select, Qt::Key_U, Qt::Key_Up, Qt::Key_Y, Qt::Key_Z, Keyboard, selectAll(), QStyle::SH_SpinBox_AnimateButton, Qt::ShiftModifier, QString::size(), stepBy(), StepDownEnabled, stepEnabled(), StepUpEnabled, QWidget::style(), styleHint(), text(), and Up.
Referenced by QDateTimeEdit::keyPressEvent().
00840 { 00841 Q_D(QAbstractSpinBox); 00842 00843 if (!event->text().isEmpty() && d->edit->cursorPosition() < d->prefix.size()) 00844 d->edit->setCursorPosition(d->prefix.size()); 00845 00846 int steps = 1; 00847 switch (event->key()) { 00848 case Qt::Key_PageUp: 00849 case Qt::Key_PageDown: 00850 steps *= 10; 00851 case Qt::Key_Up: 00852 case Qt::Key_Down: { 00853 #ifdef QT_KEYPAD_NAVIGATION 00854 if (QApplication::keypadNavigationEnabled()) { 00855 // Reserve up/down for nav - use left/right for edit. 00856 if (!hasEditFocus() && (event->key() == Qt::Key_Up 00857 || event->key() == Qt::Key_Down)) { 00858 event->ignore(); 00859 return; 00860 } 00861 } 00862 #endif 00863 event->accept(); 00864 const bool up = (event->key() == Qt::Key_PageUp || event->key() == Qt::Key_Up); 00865 if (!(stepEnabled() & (up ? StepUpEnabled : StepDownEnabled))) 00866 return; 00867 if (!up) 00868 steps *= -1; 00869 if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { 00870 d->buttonState = (Keyboard | (up ? Up : Down)); 00871 } 00872 stepBy(steps); 00873 return; 00874 } 00875 #ifdef QT_KEYPAD_NAVIGATION 00876 case Qt::Key_Left: 00877 case Qt::Key_Right: 00878 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { 00879 const bool up = (event->key() == Qt::Key_Right); 00880 if (!(stepEnabled() & (up ? StepUpEnabled : StepDownEnabled))) 00881 return; 00882 if (!up) 00883 steps *= -1; 00884 if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { 00885 d->buttonState = (Keyboard | (up ? Up : Down)); 00886 } 00887 stepBy(steps); 00888 return; 00889 } 00890 break; 00891 case Qt::Key_Back: 00892 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { 00893 event->ignore(); 00894 return; 00895 } 00896 break; 00897 #endif 00898 case Qt::Key_Enter: 00899 case Qt::Key_Return: 00900 d->interpret(AlwaysEmit); 00901 selectAll(); 00902 event->ignore(); 00903 emit editingFinished(); 00904 return; 00905 00906 #ifdef QT_KEYPAD_NAVIGATION 00907 case Qt::Key_Select: 00908 if (QApplication::keypadNavigationEnabled()) { 00909 // Toggles between left/right moving cursor and inc/dec. 00910 setEditFocus(!hasEditFocus()); 00911 if (!hasEditFocus()) 00912 selectAll(); 00913 } 00914 return; 00915 #endif 00916 00917 #ifdef Q_WS_X11 // only X11 00918 case Qt::Key_U: 00919 if (event->modifiers() & Qt::ControlModifier) { 00920 event->accept(); 00921 if (!isReadOnly()) 00922 clear(); 00923 return; 00924 } 00925 break; 00926 #else // Mac and Windows 00927 case Qt::Key_A: 00928 if (event->modifiers() & Qt::ControlModifier) { 00929 selectAll(); 00930 event->accept(); 00931 return; 00932 } 00933 break; 00934 #endif 00935 00936 case Qt::Key_End: 00937 case Qt::Key_Home: 00938 if (event->modifiers() & Qt::ShiftModifier) { 00939 int currentPos = d->edit->cursorPosition(); 00940 const QString text = d->edit->displayText(); 00941 if (event->key() == Qt::Key_End) { 00942 if ((currentPos == 0 && !d->prefix.isEmpty()) || text.size() - d->suffix.size() <= currentPos) { 00943 break; // let lineedit handle this 00944 } else { 00945 d->edit->setSelection(currentPos, text.size() - d->suffix.size() - currentPos); 00946 } 00947 } else { 00948 if ((currentPos == text.size() && !d->suffix.isEmpty()) || currentPos <= d->prefix.size()) { 00949 break; // let lineedit handle this 00950 } else { 00951 d->edit->setSelection(currentPos, d->prefix.size() - currentPos); 00952 } 00953 } 00954 event->accept(); 00955 return; 00956 } 00957 break; 00958 00959 case Qt::Key_Z: 00960 case Qt::Key_Y: 00961 if (event->modifiers() & Qt::ControlModifier) { 00962 event->ignore(); 00963 return; 00964 } 00965 break; 00966 default: 00967 break; 00968 } 00969 00970 d->edit->event(event); 00971 }
Here is the call graph for this function:

| void QAbstractSpinBox::keyReleaseEvent | ( | QKeyEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 977 of file qabstractspinbox.cpp.
References d, event(), Keyboard, QStyle::SH_SpinBox_AnimateButton, QWidget::style(), and QStyle::styleHint().
00978 { 00979 Q_D(QAbstractSpinBox); 00980 00981 if (d->buttonState & Keyboard && !event->isAutoRepeat() 00982 && style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { 00983 d->reset(); 00984 } else { 00985 d->edit->event(event); 00986 } 00987 }
Here is the call graph for this function:

| void QAbstractSpinBox::wheelEvent | ( | QWheelEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 994 of file qabstractspinbox.cpp.
References Qt::ControlModifier, event(), stepBy(), StepDownEnabled, stepEnabled(), and StepUpEnabled.
Referenced by QDateTimeEdit::wheelEvent().
00995 { 00996 const int steps = (event->delta() > 0 ? 1 : -1); 00997 if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled)) 00998 stepBy(event->modifiers() & Qt::ControlModifier ? steps * 10 : steps); 00999 event->accept(); 01000 }
Here is the call graph for this function:

| void QAbstractSpinBox::focusInEvent | ( | QFocusEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1007 of file qabstractspinbox.cpp.
References Qt::BacktabFocusReason, d, event(), QWidget::focusInEvent(), selectAll(), and Qt::TabFocusReason.
Referenced by QDateTimeEdit::focusInEvent().
01008 { 01009 Q_D(QAbstractSpinBox); 01010 01011 d->edit->event(event); 01012 if (event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason) { 01013 selectAll(); 01014 } 01015 QWidget::focusInEvent(event); 01016 }
Here is the call graph for this function:

| void QAbstractSpinBox::focusOutEvent | ( | QFocusEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1022 of file qabstractspinbox.cpp.
References d, editingFinished(), emit, EmitIfChanged, event(), and QWidget::focusOutEvent().
01023 { 01024 Q_D(QAbstractSpinBox); 01025 01026 if (d->pendingEmit) 01027 d->interpret(EmitIfChanged); 01028 01029 d->reset(); 01030 d->edit->event(event); 01031 QWidget::focusOutEvent(event); 01032 emit editingFinished(); 01033 }
Here is the call graph for this function:

| void QAbstractSpinBox::contextMenuEvent | ( | QContextMenuEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1112 of file qabstractspinbox.cpp.
References d, event(), QWidget::height(), QWidget::mapToGlobal(), QContextMenuEvent::Mouse, QWidget::pos(), QAction::setEnabled(), stepBy(), StepDownEnabled, stepEnabled(), StepUpEnabled, and QWidget::width().
01113 { 01114 #ifdef QT_NO_CONTEXTMENU 01115 Q_UNUSED(event); 01116 #else 01117 Q_D(QAbstractSpinBox); 01118 01119 d->reset(); 01120 QPointer<QMenu> menu = d->edit->createStandardContextMenu(); 01121 menu->addSeparator(); 01122 const uint se = stepEnabled(); 01123 QAction *up = menu->addAction(tr("&Step up")); 01124 up->setEnabled(se & StepUpEnabled); 01125 QAction *down = menu->addAction(tr("Step &down")); 01126 down->setEnabled(se & StepDownEnabled); 01127 01128 const QPointer<QAbstractSpinBox> that = this; 01129 const QPoint pos = (event->reason() == QContextMenuEvent::Mouse) 01130 ? event->globalPos() : mapToGlobal(QPoint(event->pos().x(), 0)) + QPoint(width() / 2, height() / 2); 01131 const QAction *action = menu->exec(pos); 01132 delete static_cast<QMenu *>(menu); 01133 if (that) { 01134 if (action == up) { 01135 stepBy(1); 01136 } else if (action == down) { 01137 stepBy(-1); 01138 } 01139 } 01140 event->accept(); 01141 #endif // QT_NO_CONTEXTMENU 01142 }
Here is the call graph for this function:

| void QAbstractSpinBox::changeEvent | ( | QEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 688 of file qabstractspinbox.cpp.
References QEvent::ActivationChange, QWidget::changeEvent(), d, EmitIfChanged, QEvent::EnabledChange, event(), QWidget::isActiveWindow(), QWidget::isEnabled(), QStyle::SH_SpinBox_ClickAutoRepeatRate, QWidget::style(), QEvent::StyleChange, QStyle::styleHint(), and thresholdTime.
00689 { 00690 Q_D(QAbstractSpinBox); 00691 00692 switch (event->type()) { 00693 case QEvent::StyleChange: 00694 d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this); 00695 d->spinClickThresholdTimerInterval = thresholdTime; 00696 d->reset(); 00697 d->updateEditFieldGeometry(); 00698 break; 00699 case QEvent::EnabledChange: 00700 if (!isEnabled()) { 00701 d->reset(); 00702 } 00703 break; 00704 case QEvent::ActivationChange: 00705 if (!isActiveWindow()){ 00706 d->reset(); 00707 if (d->pendingEmit) // pendingEmit can be true even if it hasn't changed. 00708 d->interpret(EmitIfChanged); // E.g. 10 to 10.0 00709 } 00710 break; 00711 default: 00712 break; 00713 } 00714 QWidget::changeEvent(event); 00715 }
Here is the call graph for this function:

| void QAbstractSpinBox::closeEvent | ( | QCloseEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1039 of file qabstractspinbox.cpp.
References QWidget::closeEvent(), d, EmitIfChanged, and event().
01040 { 01041 Q_D(QAbstractSpinBox); 01042 01043 d->reset(); 01044 if (d->pendingEmit) 01045 d->interpret(EmitIfChanged); 01046 QWidget::closeEvent(event); 01047 }
Here is the call graph for this function:

| void QAbstractSpinBox::hideEvent | ( | QHideEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1053 of file qabstractspinbox.cpp.
References d, EmitIfChanged, event(), and QWidget::hideEvent().
01054 { 01055 Q_D(QAbstractSpinBox); 01056 d->reset(); 01057 if (d->pendingEmit) 01058 d->interpret(EmitIfChanged); 01059 QWidget::hideEvent(event); 01060 }
Here is the call graph for this function:

| void QAbstractSpinBox::mousePressEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1171 of file qabstractspinbox.cpp.
References d, event(), Qt::LeftButton, None, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxUp, StepDownEnabled, stepEnabled(), and StepUpEnabled.
Referenced by QDateTimeEdit::mousePressEvent().
01172 { 01173 Q_D(QAbstractSpinBox); 01174 01175 if (event->button() != Qt::LeftButton || d->buttonState != None) { 01176 return; 01177 } 01178 01179 d->updateHoverControl(event->pos()); 01180 event->accept(); 01181 01182 const StepEnabled se = stepEnabled(); 01183 if ((se & StepUpEnabled) && d->hoverControl == QStyle::SC_SpinBoxUp) { 01184 d->updateState(true); 01185 } else if ((se & StepDownEnabled) && d->hoverControl == QStyle::SC_SpinBoxDown) { 01186 d->updateState(false); 01187 } else { 01188 event->ignore(); 01189 } 01190 }
Here is the call graph for this function:

| void QAbstractSpinBox::mouseReleaseEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1195 of file qabstractspinbox.cpp.
01196 { 01197 Q_D(QAbstractSpinBox); 01198 01199 if ((d->buttonState & Mouse) != 0) 01200 d->reset(); 01201 event->accept(); 01202 }
Here is the call graph for this function:

| void QAbstractSpinBox::mouseMoveEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1148 of file qabstractspinbox.cpp.
References d, event(), QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxUp, StepDownEnabled, stepEnabled(), and StepUpEnabled.
01149 { 01150 Q_D(QAbstractSpinBox); 01151 01152 d->updateHoverControl(event->pos()); 01153 01154 // If we have a timer ID, update the state 01155 const StepEnabled se = stepEnabled(); 01156 if (d->spinClickTimerId != -1) { 01157 if ((se & StepUpEnabled) && d->hoverControl == QStyle::SC_SpinBoxUp) 01158 d->updateState(true); 01159 else if ((se & StepDownEnabled) && d->hoverControl == QStyle::SC_SpinBoxDown) 01160 d->updateState(false); 01161 else 01162 d->reset(); 01163 event->accept(); 01164 } 01165 }
Here is the call graph for this function:

| void QAbstractSpinBox::timerEvent | ( | QTimerEvent * | event | ) | [protected, virtual] |
Reimplemented from QObject.
Definition at line 1066 of file qabstractspinbox.cpp.
References d, Down, event(), int, QObject::killTimer(), QObject::startTimer(), stepBy(), StepDownEnabled, stepEnabled(), StepUpEnabled, QObject::timerEvent(), and Up.
01067 { 01068 Q_D(QAbstractSpinBox); 01069 01070 bool doStep = false; 01071 if (event->timerId() == d->spinClickThresholdTimerId) { 01072 killTimer(d->spinClickThresholdTimerId); 01073 d->spinClickThresholdTimerId = -1; 01074 d->spinClickTimerId = startTimer(d->spinClickTimerInterval); 01075 doStep = true; 01076 } else if (event->timerId() == d->spinClickTimerId) { 01077 if (d->accelerate) { 01078 d->acceleration = d->acceleration + (int)(d->spinClickTimerInterval * 0.05); 01079 if (d->spinClickTimerInterval - d->acceleration >= 10) { 01080 killTimer(d->spinClickTimerId); 01081 d->spinClickTimerId = startTimer(d->spinClickTimerInterval - d->acceleration); 01082 } 01083 } 01084 doStep = true; 01085 } 01086 01087 if (doStep) { 01088 const StepEnabled st = stepEnabled(); 01089 if (d->buttonState & Up) { 01090 if (!(st & StepUpEnabled)) { 01091 d->reset(); 01092 } else { 01093 stepBy(1); 01094 } 01095 } else if (d->buttonState & Down) { 01096 if (!(st & StepDownEnabled)) { 01097 d->reset(); 01098 } else { 01099 stepBy(-1); 01100 } 01101 } 01102 return; 01103 } 01104 QWidget::timerEvent(event); 01105 return; 01106 }
Here is the call graph for this function:

| void QAbstractSpinBox::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 808 of file qabstractspinbox.cpp.
References QStyle::CC_SpinBox, d, QStyle::drawComplexControl(), p, and QWidget::style().
Referenced by QDateTimeEdit::paintEvent().
00809 { 00810 Q_D(QAbstractSpinBox); 00811 00812 QStyleOptionSpinBox opt = d->getStyleOption(); 00813 QPainter p(this); 00814 style()->drawComplexControl(QStyle::CC_SpinBox, &opt, &p, this); 00815 }
Here is the call graph for this function:

| void QAbstractSpinBox::showEvent | ( | QShowEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 676 of file qabstractspinbox.cpp.
References d.
00677 { 00678 Q_D(QAbstractSpinBox); 00679 00680 d->reset(); 00681 d->updateEdit(); 00682 }
| QLineEdit * QAbstractSpinBox::lineEdit | ( | ) | const [protected] |
This function returns a pointer to the line edit of the spin box.
Definition at line 576 of file qabstractspinbox.cpp.
References d.
Referenced by setLineEdit(), and text().
00577 { 00578 Q_D(const QAbstractSpinBox); 00579 00580 return d->edit; 00581 }
| void QAbstractSpinBox::setLineEdit | ( | QLineEdit * | lineEdit | ) | [protected] |
Sets the line edit of the spinbox to be lineEdit instead of the current line edit widget. lineEdit can not be 0.
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.
Definition at line 596 of file qabstractspinbox.cpp.
References QObject::connect(), d, QVariant::Invalid, QWidget::isVisible(), lineEdit(), Qt::NoContextMenu, SIGNAL, SLOT, and Qt::WA_InputMethodEnabled.
00597 { 00598 Q_D(QAbstractSpinBox); 00599 00600 if (!lineEdit) { 00601 Q_ASSERT(lineEdit); 00602 return; 00603 } 00604 delete d->edit; 00605 d->edit = lineEdit; 00606 if (!d->edit->validator()) 00607 d->edit->setValidator(d->validator); 00608 00609 if (d->edit->parent() != this) 00610 d->edit->setParent(this); 00611 00612 d->edit->setFrame(false); 00613 d->edit->setAttribute(Qt::WA_InputMethodEnabled, false); 00614 d->edit->setFocusProxy(this); 00615 d->edit->setAcceptDrops(false); 00616 00617 if (d->type != QVariant::Invalid) { 00618 connect(d->edit, SIGNAL(textChanged(QString)), 00619 this, SLOT(_q_editorTextChanged(QString))); 00620 connect(d->edit, SIGNAL(cursorPositionChanged(int,int)), 00621 this, SLOT(_q_editorCursorPositionChanged(int,int))); 00622 } 00623 d->updateEditFieldGeometry(); 00624 d->edit->setContextMenuPolicy(Qt::NoContextMenu); 00625 00626 if (isVisible()) 00627 d->edit->show(); 00628 if (isVisible()) 00629 d->updateEdit(); 00630 }
Here is the call graph for this function:

| QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled | ( | ) | const [protected, virtual] |
Virtual function that determines whether stepping up and down is legal at any given time.
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.
Definition at line 475 of file qabstractspinbox.cpp.
References d, QVariant::Invalid, StepDownEnabled, StepNone, and StepUpEnabled.
Referenced by contextMenuEvent(), keyPressEvent(), mouseMoveEvent(), mousePressEvent(), timerEvent(), and wheelEvent().
00476 { 00477 Q_D(const QAbstractSpinBox); 00478 if (d->readOnly || d->type == QVariant::Invalid) 00479 return StepNone; 00480 if (d->wrapping) 00481 return StepEnabled(StepUpEnabled | StepDownEnabled); 00482 StepEnabled ret = StepNone; 00483 if (d->variantCompare(d->value, d->maximum) < 0) { 00484 ret |= StepUpEnabled; 00485 } 00486 if (d->variantCompare(d->value, d->minimum) > 0) { 00487 ret |= StepDownEnabled; 00488 } 00489 return ret; 00490 }
| void QAbstractSpinBox::editingFinished | ( | ) | [signal] |
This signal is emitted editing is finished. This happens when the spinbox loses focus and when enter is pressed.
Referenced by focusOutEvent(), keyPressEvent(), QDateTimeEdit::keyPressEvent(), qdesigner_internal::QtSpinBox::stepBy(), and qdesigner_internal::QtDoubleSpinBox::stepBy().
| QAbstractSpinBox::Q_PRIVATE_SLOT | ( | d_func() | , | |
| void | _q_editorTextChanged(const QString &) | |||
| ) | [private] |
1.5.1