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

    上一话题

    QAbstractSlider

    下一话题

    QDial

    QSlider

    概要

    详细描述

    PySide.QtGui.QSlider widget provides a vertical or horizontal slider.

    滑块是用于控制有界值的经典 Widget。它让用户沿水平或垂直凹槽移动滑块手柄,并将手柄位置翻译成在合法范围内的整数值。

    PySide.QtGui.QSlider has very few of its own functions; most of the functionality is in PySide.QtGui.QAbstractSlider 。最有用的功能是 PySide.QtGui.QAbstractSlider.setValue() to set the slider directly to some value; PySide.QtGui.QAbstractSlider.triggerAction() to simulate the effects of clicking (useful for shortcut keys); PySide.QtGui.QAbstractSlider.setSingleStep() , PySide.QtGui.QAbstractSlider.setPageStep() to set the steps; and PySide.QtGui.QAbstractSlider.setMinimum() and PySide.QtGui.QAbstractSlider.setMaximum() to define the range of the scroll bar.

    PySide.QtGui.QSlider provides methods for controlling tickmarks. You can use PySide.QtGui.QSlider.setTickPosition() to indicate where you want the tickmarks to be, PySide.QtGui.QSlider.setTickInterval() to indicate how many of them you want. the currently set tick position and interval can be queried using the PySide.QtGui.QSlider.tickPosition() and PySide.QtGui.QSlider.tickInterval() functions, respectively.

    PySide.QtGui.QSlider inherits a comprehensive set of signals:

    信号 描述
    PySide.QtGui.QAbstractSlider.valueChanged() Emitted when the slider's value has changed. The tracking() determines whether this signal is emitted during user interaction.
    PySide.QtGui.QAbstractSlider.sliderPressed() 发射当用户开始拖曳滑块时。
    PySide.QtGui.QAbstractSlider.sliderMoved() 发射当用户拖曳滑块时。
    PySide.QtGui.QAbstractSlider.sliderReleased() 发射当用户释放滑块时。

    PySide.QtGui.QSlider only provides integer ranges. Note that although PySide.QtGui.QSlider handles very large numbers, it becomes difficult for users to use a slider accurately for very large ranges.

    滑块接受 Tab 聚焦,并提供鼠标滚轮及键盘接口。键盘接口如下:

    • 左/右箭头水平移动滑块一单步幅。
    • 上/下箭头垂直移动滑块一单步幅。
    • PageUp 键上移一页。
    • PageDown 键下移一页。
    • Home 键移至开头 (最小)。
    • End 键移至结束 (最大)。
    ../../_images/macintosh-slider.png A slider shown in the Macintosh widget style .
    ../../_images/windows-slider.png A slider shown in the Windows XP widget style .
    ../../_images/plastique-slider.png A slider shown in the Plastique widget style .

    另请参阅

    PySide.QtGui.QScrollBar PySide.QtGui.QSpinBox PySide.QtGui.QDial GUI Design Handbook: Slider 滑块范例

    class PySide.QtGui. QSlider ( [ parent=None ] )
    class PySide.QtGui. QSlider ( orientation [ , parent=None ] )
    参数:

    Constructs a vertical slider with the given parent .

    PySide.QtGui.QSlider. TickPosition

    This enum specifies where the tick marks are to be drawn relative to the slider's groove and the handle the user moves.

    常量 描述
    QSlider.NoTicks Do not draw any tick marks.
    QSlider.TicksBothSides Draw tick marks on both sides of the groove.
    QSlider.TicksAbove Draw tick marks above the (horizontal) slider
    QSlider.TicksBelow Draw tick marks below the (horizontal) slider
    QSlider.TicksLeft Draw tick marks to the left of the (vertical) slider
    QSlider.TicksRight Draw tick marks to the right of the (vertical) slider
    PySide.QtGui.QSlider. initStyleOption ( option )
    参数: option PySide.QtGui.QStyleOptionSlider

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

    PySide.QtGui.QSlider. setTickInterval ( ti )
    参数: ti PySide.QtCore.int

    This property holds the interval between tickmarks.

    This is a value interval, not a pixel interval. If it is 0, the slider will choose between PySide.QtGui.QAbstractSlider.singleStep() and PySide.QtGui.QAbstractSlider.pageStep() .

    默认值为 0。

    PySide.QtGui.QSlider. setTickPosition ( position )
    参数: position PySide.QtGui.QSlider.TickPosition

    This property holds the tickmark position for this slider.

    The valid values are described by the QSlider.TickPosition 枚举。

    默认值为 QSlider.NoTicks .

    PySide.QtGui.QSlider. tickInterval ( )
    返回类型: PySide.QtCore.int

    This property holds the interval between tickmarks.

    This is a value interval, not a pixel interval. If it is 0, the slider will choose between PySide.QtGui.QAbstractSlider.singleStep() and PySide.QtGui.QAbstractSlider.pageStep() .

    默认值为 0。

    PySide.QtGui.QSlider. tickPosition ( )
    返回类型: PySide.QtGui.QSlider.TickPosition

    This property holds the tickmark position for this slider.

    The valid values are described by the QSlider.TickPosition 枚举。

    默认值为 QSlider.NoTicks .