内容表

上一话题

QSizePolicy

下一话题

QSpacerItem

QSlider

QSlider widget provides a vertical or horizontal slider. 更多

Inheritance diagram of PySide2.QtWidgets.QSlider

概要

详细描述

../../_images/windows-slider.png

The slider is the classic widget for controlling a bounded value. It lets the user move a slider handle along a horizontal or vertical groove and translates the handle’s position into an integer value within the legal range.

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

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

QSlider inherits a comprehensive set of signals:

信号

描述

valueChanged()

Emitted when the slider’s value has changed. The tracking() determines whether this signal is emitted during user interaction.

sliderPressed()

发射当用户开始拖曳滑块时。

sliderMoved()

发射当用户拖曳滑块时。

sliderReleased()

发射当用户释放滑块时。

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

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

  • 左/右箭头水平移动滑块一单步幅。

  • 上/下箭头垂直移动滑块一单步幅。

  • PageUp 键上移一页。

  • PageDown 键下移一页。

  • Home 键移至开头 (最小)。

  • End 键移至结束 (最大)。

class QSlider ( [ parent=None ] )

QSlider(orientation[, parent=None])

param parent

QWidget

param orientation

取向

Constructs a vertical slider with the given parent .

Constructs a slider with the given parent orientation parameter determines whether the slider is horizontal or vertical; the valid values are Vertical and Horizontal .

PySide2.QtWidgets.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

PySide2.QtWidgets.QSlider. initStyleOption ( option )
参数

option QStyleOptionSlider

初始化 option 采用值来自此 QSlider 。此方法对子类是有用的,当需要 QStyleOptionSlider , but don’t want to fill in all the information themselves.

另请参阅

initFrom()

PySide2.QtWidgets.QSlider. setTickInterval ( ti )
参数

ti int

另请参阅

tickInterval()

PySide2.QtWidgets.QSlider. setTickPosition ( position )
参数

position TickPosition

另请参阅

tickPosition()

PySide2.QtWidgets.QSlider. tickInterval ( )
返回类型

int

另请参阅

setTickInterval()

PySide2.QtWidgets.QSlider. tickPosition ( )
返回类型

TickPosition

另请参阅

setTickPosition()