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 聚焦,并提供鼠标滚轮及键盘接口。键盘接口如下:
|
A slider shown in the Macintosh widget style . |
|
A slider shown in the Windows XP widget style . |
|
A slider shown in the Plastique widget style . |
另请参阅
PySide.QtGui.QScrollBar PySide.QtGui.QSpinBox PySide.QtGui.QDial GUI Design Handbook: Slider 滑块范例
| 参数: |
|
|---|
Constructs a vertical slider with the given parent .
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 |
| 参数: | option – PySide.QtGui.QStyleOptionSlider |
|---|
初始化 option 采用值来自此 PySide.QtGui.QSlider 。此方法对子类是有用的,当需要 PySide.QtGui.QStyleOptionSlider ,但不希望自己填充所有信息。
| 参数: | 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。
| 参数: | 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.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 |
|---|
This property holds the tickmark position for this slider.
The valid values are described by the QSlider.TickPosition 枚举。
默认值为 QSlider.NoTicks .