QSlider¶
Synopsis¶
Functions¶
def
initStyleOption
(option)def
setTickInterval
(ti)def
setTickPosition
(position)def
tickInterval
()def
tickPosition
()
Detailed Description¶
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 inQAbstractSlider
. The most useful functions aresetValue()
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; andsetMinimum()
andsetMaximum()
to define the range of the scroll bar.
QSlider
provides methods for controlling tickmarks. You can usesetTickPosition()
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 thetickPosition()
andtickInterval()
functions, respectively.
QSlider
inherits a comprehensive set of signals:
Signal
Description
Emitted when the slider’s value has changed. The tracking() determines whether this signal is emitted during user interaction.
Emitted when the user starts to drag the slider.
Emitted when the user drags the slider.
Emitted when the user releases the slider.
QSlider
only provides integer ranges. Note that althoughQSlider
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 (minimum).
End moves to the end (maximum).
- class PySide2.QtWidgets.QSlider([parent=None])¶
PySide2.QtWidgets.QSlider(orientation[, parent=None])
- param parent:
- param orientation:
Constructs a vertical slider with the given
parent
.Constructs a slider with the given
parent
. Theorientation
parameter determines whether the slider is horizontal or vertical; the valid values areVertical
andHorizontal
.
- 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.
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
- PySide2.QtWidgets.QSlider.initStyleOption(option)¶
- Parameters:
option –
PySide2.QtWidgets.QStyleOptionSlider
Initialize
option
with the values from thisQSlider
. This method is useful for subclasses when they need aQStyleOptionSlider
, but don’t want to fill in all the information themselves.See also
- PySide2.QtWidgets.QSlider.setTickInterval(ti)¶
- Parameters:
ti – 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
singleStep
andpageStep
.The default value is 0.
See also
- PySide2.QtWidgets.QSlider.setTickPosition(position)¶
- Parameters:
position –
TickPosition
This property holds the tickmark position for this slider.
The valid values are described by the
TickPosition
enum.The default value is
NoTicks
.See also
- PySide2.QtWidgets.QSlider.tickInterval()¶
- Return type:
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
singleStep
andpageStep
.The default value is 0.
See also
- PySide2.QtWidgets.QSlider.tickPosition()¶
- Return type:
This property holds the tickmark position for this slider.
The valid values are described by the
TickPosition
enum.The default value is
NoTicks
.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.