QSlider Class Reference

[ QtGui module]

QSlider 小部件提供垂直 (或水平) 滑块。 更多...

继承 QAbstractSlider .

类型

方法


详细描述

QSlider 小部件提供垂直 (或水平) 滑块。

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 . The most useful functions are setValue () to set the slider directly to some value; triggerAction () 到 simulate the effects of clicking (useful for shortcut keys); setSingleStep (), setPageStep () 到 set the steps; and setMinimum () 和 setMaximum () to define the range of the scroll bar.

QSlider 提供用于控制刻度线的方法。可以使用 setTickPosition () 到 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 () 和 tickInterval () functions, 分别。

QSlider 继承一组综合信号:

Signal 描述
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.

A slider accepts focus on Tab and provides both a mouse wheel and a keyboard interface. The keyboard interface is the following:

Screenshot of a Macintosh slider A slider shown in the Macintosh widget style .
Screenshot of a Windows XP slider A slider shown in the Windows XP widget style .
Screenshot of a Plastique slider A slider shown in the Plastique widget style .

类型文档编制

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 0 Do not draw any tick marks.
QSlider.TicksBothSides 3 Draw tick marks on both sides of the groove.
QSlider.TicksAbove 1 Draw tick marks above the (horizontal) slider
QSlider.TicksBelow 2 Draw tick marks below the (horizontal) slider
QSlider.TicksLeft TicksAbove Draw tick marks to the left of the (vertical) slider
QSlider.TicksRight TicksBelow Draw tick marks to the right of the (vertical) slider

方法文档编制

QSlider.__init__ ( self , QWidget   parent  = None)

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

Constructs a vertical slider with the given parent .

QSlider.__init__ ( self , Qt.Orientation   orientation , QWidget   parent  = None)

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

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

bool QSlider.event ( self , QEvent   event )

重实现自 QObject.event ().

QSlider.initStyleOption ( self , QStyleOptionSlider   option )

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

另请参阅 QStyleOption.initFrom ().

QSize QSlider.minimumSizeHint ( self )

重实现自 QWidget.minimumSizeHint ().

QSlider.mouseMoveEvent ( self , QMouseEvent   ev )

重实现自 QWidget.mouseMoveEvent ().

QSlider.mousePressEvent ( self , QMouseEvent   ev )

重实现自 QWidget.mousePressEvent ().

QSlider.mouseReleaseEvent ( self , QMouseEvent   ev )

重实现自 QWidget.mouseReleaseEvent ().

QSlider.paintEvent ( self , QPaintEvent   ev )

重实现自 QWidget.paintEvent ().

QSlider.setTickInterval ( self , int  ti )

QSlider.setTickPosition ( self , TickPosition   position )

QSize QSlider.sizeHint ( self )

重实现自 QWidget.sizeHint ().

int QSlider.tickInterval ( self )

TickPosition QSlider.tickPosition ( self )