QAbstractSpinBox Class Reference

[ QtGui module]

The QAbstractSpinBox class provides a spinbox and a line edit to display values. 更多...

继承 QWidget .

Inherited by QDateTimeEdit , QDoubleSpinBox and QSpinBox .

类型

方法

Qt Signals


详细描述

The QAbstractSpinBox class provides a spinbox and a line edit to display values.

此类被设计作为 Widget 的通用超类像 QSpinBox , QDoubleSpinBox and QDateTimeEdit

这里是类的主要特性:

  1. text : The text that is displayed in the QAbstractSpinBox.
  2. alignment : The alignment of the text in the QAbstractSpinBox.
  3. wrapping : Whether the QAbstractSpinBox wraps from the minimum value to the maximum value and vica versa.

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 将触发调用 stepBy(-1).

QAbstractSpinBox 还提供虚函数 stepEnabled () to determine whether stepping up/down is allowed at any point. This function returns a bitset of StepEnabled .


类型文档编制

QAbstractSpinBox.ButtonSymbols

This enum type describes the symbols that can be displayed on the buttons in a spin box.

常量 描述
QAbstractSpinBox.UpDownArrows 0 经典风格小箭头。
QAbstractSpinBox.PlusMinus 1 + and - 符号。
QAbstractSpinBox.NoButtons 2 不显示按钮。

另请参阅 QAbstractSpinBox.buttonSymbols .

QAbstractSpinBox.CorrectionMode

This enum type describes the mode the spinbox will use to correct an 中间体 值若编辑完成。

常量 描述
QAbstractSpinBox.CorrectToPreviousValue 0 The spinbox will revert to the last valid 值。
QAbstractSpinBox.CorrectToNearestValue 1 The spinbox will revert to the nearest valid 值。

另请参阅 correctionMode .

QAbstractSpinBox.StepEnabledFlag

常量
QAbstractSpinBox.StepNone 0x00
QAbstractSpinBox.StepUpEnabled 0x01
QAbstractSpinBox.StepDownEnabled 0x02

The StepEnabled type is a typedef for QFlags <StepEnabledFlag>. It stores an OR combination of StepEnabledFlag values.


方法文档编制

QAbstractSpinBox.__init__ ( self , QWidget   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

构造抽象 Spinbox 采用给定 parent with default wrapping , and alignment 特性。

Qt.Alignment QAbstractSpinBox.alignment ( self )

ButtonSymbols QAbstractSpinBox.buttonSymbols ( self )

QAbstractSpinBox.changeEvent ( self , QEvent   e )

重实现自 QWidget.changeEvent ().

QAbstractSpinBox.clear ( self )

This method is also a Qt slot with the C++ signature void clear() .

清零所有文本的 lineedit,除前缀和后缀外。

QAbstractSpinBox.closeEvent ( self , QCloseEvent   e )

重实现自 QWidget.closeEvent ().

QAbstractSpinBox.contextMenuEvent ( self , QContextMenuEvent   e )

重实现自 QWidget.contextMenuEvent ().

CorrectionMode QAbstractSpinBox.correctionMode ( self )

bool QAbstractSpinBox.event ( self , QEvent   event )

重实现自 QObject.event ().

QString  input QAbstractSpinBox.fixup ( self , QString  input )

This virtual function is called by the QAbstractSpinBox input is not validated to QValidator.Acceptable when Return is pressed or interpretText () 是 called. It will try to change the text so it is valid. Reimplemented in the various subclasses.

QAbstractSpinBox.fixup ( self , QString  input )

QAbstractSpinBox.focusInEvent ( self , QFocusEvent   e )

重实现自 QWidget.focusInEvent ().

QAbstractSpinBox.focusOutEvent ( self , QFocusEvent   e )

重实现自 QWidget.focusOutEvent ().

bool QAbstractSpinBox.hasAcceptableInput ( self )

bool QAbstractSpinBox.hasFrame ( self )

QAbstractSpinBox.hideEvent ( self , QHideEvent   e )

重实现自 QWidget.hideEvent ().

QAbstractSpinBox.initStyleOption ( self , QStyleOptionSpinBox   option )

初始化 option 采用值来自此 QSpinBox . This method is useful for subclasses when they need a QStyleOptionSpinBox , but don't want to fill in all the information themselves.

另请参阅 QStyleOption.initFrom ().

QVariant QAbstractSpinBox.inputMethodQuery ( self , Qt.InputMethodQuery )

重实现自 QWidget.inputMethodQuery ().

QAbstractSpinBox.interpretText ( self )

This function interprets the text of the spin box. If the value has changed since last interpretation it will emit signals.

bool QAbstractSpinBox.isAccelerated ( self )

bool QAbstractSpinBox.isReadOnly ( self )

bool QAbstractSpinBox.keyboardTracking ( self )

QAbstractSpinBox.keyPressEvent ( self , QKeyEvent   e )

重实现自 QWidget.keyPressEvent ().

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.
向上 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)

QAbstractSpinBox.keyReleaseEvent ( self , QKeyEvent   e )

重实现自 QWidget.keyReleaseEvent ().

QLineEdit QAbstractSpinBox.lineEdit ( self )

This function returns a pointer to the line edit of the spin box.

另请参阅 setLineEdit ().

QSize QAbstractSpinBox.minimumSizeHint ( self )

重实现自 QWidget.minimumSizeHint ().

QAbstractSpinBox.mouseMoveEvent ( self , QMouseEvent   e )

重实现自 QWidget.mouseMoveEvent ().

QAbstractSpinBox.mousePressEvent ( self , QMouseEvent   e )

重实现自 QWidget.mousePressEvent ().

QAbstractSpinBox.mouseReleaseEvent ( self , QMouseEvent   e )

重实现自 QWidget.mouseReleaseEvent ().

QAbstractSpinBox.paintEvent ( self , QPaintEvent   e )

重实现自 QWidget.paintEvent ().

QAbstractSpinBox.resizeEvent ( self , QResizeEvent   e )

重实现自 QWidget.resizeEvent ().

QAbstractSpinBox.selectAll ( self )

This method is also a Qt slot with the C++ signature void selectAll() .

Selects all the text in the spinbox except the prefix and suffix.

QAbstractSpinBox.setAccelerated ( self , bool  on )

QAbstractSpinBox.setAlignment ( self , Qt.Alignment   flag )

QAbstractSpinBox.setButtonSymbols ( self , ButtonSymbols   bs )

QAbstractSpinBox.setCorrectionMode ( self , CorrectionMode   cm )

QAbstractSpinBox.setFrame ( self , bool)

QAbstractSpinBox.setKeyboardTracking ( self , bool  kt )

QAbstractSpinBox.setLineEdit ( self , QLineEdit   e )

e argument has it's ownership transferred to Qt.

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

QLineEdit.validator () 为 lineEdit returns 0, the internal validator of the spinbox will be set on the line edit.

另请参阅 lineEdit ().

QAbstractSpinBox.setReadOnly ( self , bool  r )

QAbstractSpinBox.setSpecialValueText ( self , QString  s )

QAbstractSpinBox.setWrapping ( self , bool  w )

QAbstractSpinBox.showEvent ( self , QShowEvent   e )

重实现自 QWidget.showEvent ().

QSize QAbstractSpinBox.sizeHint ( self )

重实现自 QWidget.sizeHint ().

QString QAbstractSpinBox.specialValueText ( self )

QAbstractSpinBox.stepBy ( self , int  steps )

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 将触发调用 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.

QAbstractSpinBox.stepDown ( self )

This method is also a Qt slot with the C++ signature void stepDown() .

Steps down by one linestep Calling this slot is analogous to calling stepBy(-1);

另请参阅 stepBy () 和 stepUp ().

StepEnabled QAbstractSpinBox.stepEnabled ( self )

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.

另请参阅 QSpinBox.minimum (), QSpinBox.maximum (),和 wrapping ().

QAbstractSpinBox.stepUp ( self )

This method is also a Qt slot with the C++ signature void stepUp() .

Steps up by one linestep Calling this slot is analogous to calling stepBy(1);

另请参阅 stepBy () 和 stepDown ().

QString QAbstractSpinBox.text ( self )

QAbstractSpinBox.timerEvent ( self , QTimerEvent   e )

重实现自 QObject.timerEvent ().

( QValidator.State , QString  input , int  pos ) QAbstractSpinBox.validate ( self , QString  input , int  pos )

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 子类。

( QValidator.State , int  pos ) QAbstractSpinBox.validate ( self , QString  input , int  pos )

QAbstractSpinBox.wheelEvent ( self , QWheelEvent   e )

重实现自 QWidget.wheelEvent ().

bool QAbstractSpinBox.wrapping ( self )


Qt Signal Documentation

void editingFinished ()

This is the default overload of this signal.

This signal is emitted editing is finished. This happens when the spinbox loses focus and when enter is pressed.