Table Of Contents

Previous topic

QAbstractSlider

Next topic

QDial

QSlider

Synopsis

Functions

Detailed Description

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

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.

PySide.QtGui.QSlider has very few of its own functions; most of the functionality is in PySide.QtGui.QAbstractSlider . The most useful functions are 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:

Signal Description
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() Emitted when the user starts to drag the slider.
PySide.QtGui.QAbstractSlider.sliderMoved() Emitted when the user drags the slider.
PySide.QtGui.QAbstractSlider.sliderReleased() Emitted when the user releases the slider.

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.

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

  • Left/Right move a horizontal slider by one single step.
  • Up/Down move a vertical slider by one single step.
  • PageUp moves up one page.
  • PageDown moves down one page.
  • Home moves to the start (mininum).
  • End moves to the end (maximum).
../../_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 .

See also

PySide.QtGui.QScrollBar PySide.QtGui.QSpinBox PySide.QtGui.QDial GUI Design Handbook: Slider Sliders Example

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

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.

Constant Description
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)
Parameters:optionPySide.QtGui.QStyleOptionSlider

Initialize option with the values from this PySide.QtGui.QSlider . This method is useful for subclasses when they need a PySide.QtGui.QStyleOptionSlider , but don’t want to fill in all the information themselves.

PySide.QtGui.QSlider.setTickInterval(ti)
Parameters:tiPySide.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() .

The default value is 0.

PySide.QtGui.QSlider.setTickPosition(position)
Parameters:positionPySide.QtGui.QSlider.TickPosition

This property holds the tickmark position for this slider.

The valid values are described by the QSlider.TickPosition enum.

The default value is QSlider.NoTicks .

PySide.QtGui.QSlider.tickInterval()
Return type: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() .

The default value is 0.

PySide.QtGui.QSlider.tickPosition()
Return type:PySide.QtGui.QSlider.TickPosition

This property holds the tickmark position for this slider.

The valid values are described by the QSlider.TickPosition enum.

The default value is QSlider.NoTicks .