15#include <QtCore/qelapsedtimer.h>
17#if QT_CONFIG(accessibility)
165 q->update(lastHoverRect);
175 QStyleOptionSlider
opt;
176 q->initStyleOption(&
opt);
191 if (
q->isVisible()) {
192 QStyleOptionSlider
opt;
193 q->initStyleOption(&
opt);
205 QStyleOptionSlider
opt;
206 q->initStyleOption(&
opt);
245 q_func()->setRepeatAction(action, threshold);
246 q_func()->triggerAction(action);
258 q->setSliderDown(
false);
260 QStyleOptionSlider
opt;
261 q->initStyleOption(&
opt);
281 option->orientation =
d->orientation;
284 option->sliderPosition =
d->position;
285 option->sliderValue =
d->value;
286 option->singleStep =
d->singleStep;
287 option->pageStep =
d->pageStep;
288 option->upsideDown =
d->invertedAppearance;
296#define HORIZONTAL (d_func()->orientation == Qt::Horizontal)
297#define VERTICAL !HORIZONTAL
357 q->setSizePolicy(
sp);
362#ifndef QT_NO_CONTEXTMENU
386 if (actionSelected ==
nullptr)
388 else if (actionSelected == actScrollHere)
389 setValue(d_func()->pixelPosToRangeValue(horiz ?
event->pos().x() :
event->pos().y()));
390 else if (actionSelected == actScrollTop)
392 else if (actionSelected == actScrollBottom)
394 else if (actionSelected == actPageUp)
396 else if (actionSelected == actPageDn)
398 else if (actionSelected == actScrollUp)
400 else if (actionSelected == actScrollDn)
411 QStyleOptionSlider
opt;
418 size =
QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent);
420 size =
QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin);
437 switch(
event->type()) {
442 d_func()->updateHoverControl(he->position().toPoint());
445 QStyleOptionSlider
opt;
452 QStyleOptionSlider
opt;
471#if QT_CONFIG(wheelevent)
472void QScrollBar::wheelEvent(QWheelEvent *
event)
486 int delta = horizontal ? -
event->angleDelta().x() :
event->angleDelta().y();
492 d->setTransient(
false);
494 d->setTransient(
true);
505 QStyleOptionSlider
opt;
508 if (
d->pressedControl) {
510 if (!
d->pointerOutsidePressedControl)
525 if (
d->repeatActionTimer.isActive())
526 d->stopRepeatAction();
530 QStyleOptionSlider
opt;
532 opt.keyboardModifiers =
e->modifiers();
534 if (
d->maximum ==
d->minimum
535 || (
e->buttons() & (~
e->button()))
540 d->pointerOutsidePressedControl =
false;
544 QPoint click =
e->position().toPoint();
546 d->pressValue =
d->orientation ==
Qt::Horizontal ?
d->pixelPosToRangeValue(pressValue.
x()) :
547 d->pixelPosToRangeValue(pressValue.
y());
550 d->snapBackPosition =
d->position;
560 :
e->position().toPoint().y()) - sliderLength / 2));
562 d->clickOffset = sliderLength / 2;
564 const int initialDelay = 500;
567 d->activateControl(
d->pressedControl, initialDelay);
569 if (
time.elapsed() >= initialDelay &&
d->repeatActionTimer.isActive()) {
576 d->repeatActionTimer.start(50,
this);
589 if (!
d->pressedControl)
592 if (
e->buttons() & (~
e->button()))
595 d->stopRepeatAction();
605 if (!
d->pressedControl)
608 QStyleOptionSlider
opt;
616 QPoint click =
e->position().toPoint();
617 int newPosition =
d->pixelPosToRangeValue((
HORIZONTAL ? click.
x() : click.
y()) -
d->clickOffset);
621 r.adjust(-
m, -
m,
m,
m);
622 if (!
r.contains(
e->position().toPoint()))
623 newPosition =
d->snapBackPosition;
631 if (newSc ==
d->pressedControl && !
d->pointerOutsidePressedControl)
634 d->pointerOutsidePressedControl =
false;
637 d->pressedControl = newSc;
638 d->activateControl(
d->pressedControl, 0);
647 if (pr.
contains(
e->position().toPoint()) ==
d->pointerOutsidePressedControl) {
648 if ((
d->pointerOutsidePressedControl = !
d->pointerOutsidePressedControl)) {
649 d->pointerOutsidePressedControl =
true;
653 d->activateControl(
d->pressedControl);
663 QStyleOptionSlider
opt;
664 q->initStyleOption(&
opt);
669 int sliderMin, sliderMax, sliderLength;
672 sliderLength = sr.
width();
674 sliderMax = gr.
right() - sliderLength + 1;
676 opt.upsideDown = !
opt.upsideDown;
678 sliderLength = sr.
height();
680 sliderMax = gr.
bottom() - sliderLength + 1;
684 sliderMax - sliderMin,
opt.upsideDown);
692 if (
d->pressedControl) {
703 QStyleOptionSlider
opt;
710#include "moc_qscrollbar.cpp"
Qt::Orientation orientation
The QAbstractSlider class provides an integer value within a range.
void setRepeatAction(SliderAction action, int thresholdTime=500, int repeatTime=50)
Sets action action to be triggered repetitively in intervals of repeatTime, after an initial delay of...
virtual void sliderChange(SliderChange change)
Reimplement this virtual function to track slider changes such as \l SliderRangeChange,...
SliderAction
\value SliderNoAction \value SliderSingleStepAdd \value SliderSingleStepSub \value SliderPageStepAdd ...
Qt::Orientation orientation
the orientation of the slider
bool event(QEvent *e) override
\reimp
void setSliderPosition(int)
SliderChange
\value SliderRangeChange \value SliderOrientationChange \value SliderStepsChange \value SliderValueCh...
void triggerAction(SliderAction action)
Triggers a slider action.
The QAction class provides an abstraction for user commands that can be added to different user inter...
The QHideEvent class provides an event which is sent after a widget is hidden.
void killTimer(int id)
Kills the timer with timer identifier, id.
The QPaintEvent class contains event parameters for paint events.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=nullptr) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_ScrollBar_RollBetweenButtons
@ SH_ScrollBar_MiddleClickAbsolutePosition
@ SH_ScrollBar_LeftClickAbsolutePosition
@ SH_ScrollBar_ContextMenu
@ SH_ScrollBar_ScrollWhenPointerLeavesControl
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=nullptr) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
static int sliderValueFromPosition(int min, int max, int pos, int space, bool upsideDown=false)
Converts the given pixel position to a logical value.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
SubControl
This enum describes the available sub controls.
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
@ WA_WState_OwnSizePolicy
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr T qAbs(const T &t)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble q
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent