• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QSplitter

    下一话题

    QDateTimeEdit

    QAbstractSpinBox

    继承者: QDateTimeEdit , QTimeEdit , QDateEdit , QDoubleSpinBox , QSpinBox

    详细描述

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

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

    这里是类的主要特性:

    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 .

    class PySide.QtGui. QAbstractSpinBox ( [ parent=None ] )
    参数: parent PySide.QtGui.QWidget

    构造抽象 Spinbox 采用给定 parent 采用默认 PySide.QtGui.QAbstractSpinBox.wrapping() ,和 PySide.QtGui.QAbstractSpinBox.alignment() 特性。

    PySide.QtGui.QAbstractSpinBox. StepEnabledFlag
    常量 描述
    QAbstractSpinBox.StepNone  
    QAbstractSpinBox.StepUpEnabled  
    QAbstractSpinBox.StepDownEnabled  
    PySide.QtGui.QAbstractSpinBox. CorrectionMode

    此枚举类型描述的自旋框模式用于校正 中间体 值若编辑完成。

    常量 描述
    QAbstractSpinBox.CorrectToPreviousValue The spinbox will revert to the last valid value.
    QAbstractSpinBox.CorrectToNearestValue The spinbox will revert to the nearest valid value.
    PySide.QtGui.QAbstractSpinBox. ButtonSymbols

    此枚举类型描述可以在自旋框按钮中显示的符号。

    PySide/QtGui/../../../../../../qt-everywhere-opensource-src-4.8.5/doc/src/images/qspinbox-updown.png..image::../../../../../../qt-everywhere-opensource-src-4.8.5/doc/src/images/qspinbox-plusminus.png
    常量 描述
    QAbstractSpinBox.UpDownArrows 经典风格小箭头。
    QAbstractSpinBox.PlusMinus + and - 符号。
    QAbstractSpinBox.NoButtons 不显示按钮。
    PySide.QtGui.QAbstractSpinBox. alignment ( )
    返回类型: PySide.QtCore.Qt.Alignment

    This property holds the alignment of the spin box.

    可能的值是 Qt.AlignLeft , Qt.AlignRight ,和 Qt.AlignHCenter .

    默认情况下,对齐方式为 Qt.AlignLeft

    试图把对齐方式设为非法标志的组合,会什么都不做。

    另请参阅

    Qt.Alignment

    PySide.QtGui.QAbstractSpinBox. buttonSymbols ( )
    返回类型: PySide.QtGui.QAbstractSpinBox.ButtonSymbols

    This property holds the current button symbol mode.

    可能值可以是 UpDownArrows or PlusMinus 。默认为 UpDownArrows .

    注意:某些风格可能渲染 PlusMinus and UpDownArrows 同等。

    另请参阅

    QAbstractSpinBox.ButtonSymbols

    PySide.QtGui.QAbstractSpinBox. clear ( )

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

    PySide.QtGui.QAbstractSpinBox. correctionMode ( )
    返回类型: PySide.QtGui.QAbstractSpinBox.CorrectionMode

    此特性保持的模式用于校正 中间体 值若编辑完成。

    默认模式为 QAbstractSpinBox.CorrectToPreviousValue .

    PySide.QtGui.QAbstractSpinBox. editingFinished ( )
    PySide.QtGui.QAbstractSpinBox. fixup ( input )
    参数: input – unicode

    This virtual function is called by the PySide.QtGui.QAbstractSpinBox 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.

    PySide.QtGui.QAbstractSpinBox. hasAcceptableInput ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the input satisfies the current validation.

    PySide.QtGui.QAbstractSpinBox. hasFrame ( )
    返回类型: 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.

    PySide.QtGui.QAbstractSpinBox. initStyleOption ( option )
    参数: option PySide.QtGui.QStyleOptionSpinBox

    初始化 option 采用值来自此 PySide.QtGui.QSpinBox 。此方法对子类是有用的,当需要 PySide.QtGui.QStyleOptionSpinBox ,但不希望自己填充所有信息。

    PySide.QtGui.QAbstractSpinBox. interpretText ( )

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

    PySide.QtGui.QAbstractSpinBox. isAccelerated ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the spin box will accelerate the frequency of the steps when pressing the step Up/Down buttons..

    若启用,自旋框会更快地递增/递减值,当按下按钮时间越长时。

    PySide.QtGui.QAbstractSpinBox. isReadOnly ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the spin box is read only..

    在只读模式下,用户仍可以将文本拷贝到剪贴板,或拖放文本;但无法编辑它。

    PySide.QtGui.QLineEdit PySide.QtGui.QAbstractSpinBox 在只读模式下不展示光标。

    另请参阅

    QLineEdit.readOnly

    PySide.QtGui.QAbstractSpinBox. keyboardTracking ( )
    返回类型: 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.

    PySide.QtGui.QAbstractSpinBox. lineEdit ( )
    返回类型: PySide.QtGui.QLineEdit

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

    PySide.QtGui.QAbstractSpinBox. selectAll ( )

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

    PySide.QtGui.QAbstractSpinBox. setAccelerated ( on )
    参数: 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..

    若启用,自旋框会更快地递增/递减值,当按下按钮时间越长时。

    PySide.QtGui.QAbstractSpinBox. setAlignment ( flag )
    参数: flag PySide.QtCore.Qt.Alignment

    This property holds the alignment of the spin box.

    可能的值是 Qt.AlignLeft , Qt.AlignRight ,和 Qt.AlignHCenter .

    默认情况下,对齐方式为 Qt.AlignLeft

    试图把对齐方式设为非法标志的组合,会什么都不做。

    另请参阅

    Qt.Alignment

    PySide.QtGui.QAbstractSpinBox. setButtonSymbols ( bs )
    参数: bs PySide.QtGui.QAbstractSpinBox.ButtonSymbols

    This property holds the current button symbol mode.

    可能值可以是 UpDownArrows or PlusMinus 。默认为 UpDownArrows .

    注意:某些风格可能渲染 PlusMinus and UpDownArrows 同等。

    另请参阅

    QAbstractSpinBox.ButtonSymbols

    PySide.QtGui.QAbstractSpinBox. setCorrectionMode ( cm )
    参数: cm PySide.QtGui.QAbstractSpinBox.CorrectionMode

    此特性保持的模式用于校正 中间体 值若编辑完成。

    默认模式为 QAbstractSpinBox.CorrectToPreviousValue .

    PySide.QtGui.QAbstractSpinBox. setFrame ( arg__1 )
    参数: 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.

    PySide.QtGui.QAbstractSpinBox. setKeyboardTracking ( kt )
    参数: 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.

    PySide.QtGui.QAbstractSpinBox. setLineEdit ( edit )
    参数: 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

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

    PySide.QtGui.QAbstractSpinBox. setReadOnly ( r )
    参数: r PySide.QtCore.bool

    This property holds whether the spin box is read only..

    在只读模式下,用户仍可以将文本拷贝到剪贴板,或拖放文本;但无法编辑它。

    PySide.QtGui.QLineEdit PySide.QtGui.QAbstractSpinBox 在只读模式下不展示光标。

    另请参阅

    QLineEdit.readOnly

    PySide.QtGui.QAbstractSpinBox. setSpecialValueText ( txt )
    参数: txt – unicode

    This property holds the special-value text.

    若设置,自旋框会显示此文本而非数字值,在当前值等于 minimum() 时。典型用途是指示此抉择具有特殊 (默认) 含义。

    例如,若自旋框允许用户选取比例因子 (或缩放级别) 为显示图像,且应用程序能够自动选取允许把图像完整拟合在显示窗口中的某一值,就可以像这样设置自旋框:

    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.

    所有被显示值带前缀和后缀 (若有设置), except 为特殊值,仅展示特殊值文本。此特殊文本被传入 QSpinBox.valueChanged() signal that passes a PySide.QtCore.QString .

    要关闭特殊值文本显示,调用此函数采用空字符串。默认为无特殊值文本 (即:照常展示数字值)。

    If no special-value text is set, PySide.QtGui.QAbstractSpinBox.specialValueText() returns an empty string.

    PySide.QtGui.QAbstractSpinBox. setWrapping ( w )
    参数: 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
    										
    PySide.QtGui.QAbstractSpinBox. specialValueText ( )
    返回类型: unicode

    This property holds the special-value text.

    若设置,自旋框会显示此文本而非数字值,在当前值等于 minimum() 时。典型用途是指示此抉择具有特殊 (默认) 含义。

    例如,若自旋框允许用户选取比例因子 (或缩放级别) 为显示图像,且应用程序能够自动选取允许把图像完整拟合在显示窗口中的某一值,就可以像这样设置自旋框:

    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.

    所有被显示值带前缀和后缀 (若有设置), except 为特殊值,仅展示特殊值文本。此特殊文本被传入 QSpinBox.valueChanged() signal that passes a PySide.QtCore.QString .

    要关闭特殊值文本显示,调用此函数采用空字符串。默认为无特殊值文本 (即:照常展示数字值)。

    If no special-value text is set, PySide.QtGui.QAbstractSpinBox.specialValueText() returns an empty string.

    PySide.QtGui.QAbstractSpinBox. stepBy ( steps )
    参数: 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.

    PySide.QtGui.QAbstractSpinBox. stepDown ( )

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

    PySide.QtGui.QAbstractSpinBox. stepEnabled ( )
    返回类型: 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.

    PySide.QtGui.QAbstractSpinBox. stepUp ( )

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

    PySide.QtGui.QAbstractSpinBox. text ( )
    返回类型: unicode

    This property holds the spin box's text, including any prefix and suffix.

    没有默认文本。

    PySide.QtGui.QAbstractSpinBox. validate ( input , pos )
    参数:
    • input – unicode
    • pos PySide.QtCore.int
    返回类型:

    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.

    PySide.QtGui.QAbstractSpinBox. wrapping ( )
    返回类型: 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