44 #ifndef QT_NO_ACCESSIBILITY 52 #include "private/qabstractslider_p.h" 96 q->initStyleOption(&opt);
104 q->initStyleOption(&opt);
107 int sliderMin, sliderMax, sliderLength;
110 sliderLength = sr.
width();
112 sliderMax = gr.
right() - sliderLength + 1;
114 sliderLength = sr.
height();
116 sliderMax = gr.
bottom() - sliderLength + 1;
150 : (!
d->invertedAppearance);
167 q->update(lastHoverRect);
178 q->initStyleOption(&opt);
187 }
else if (grooveRect.
contains(pos)) {
190 }
else if (tickmarksRect.
contains(pos)) {
380 d->minimum = minValue;
381 d->maximum = maxValue;
383 d->position =
d->value =
value;
409 if (
d->pressedControl) {
427 switch(event->
type()) {
431 if (
const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
432 d->updateHoverControl(he->pos());
436 d->resetLayoutItemMargins();
454 #ifdef QT_KEYPAD_NAVIGATION 455 if (QApplication::keypadNavigationEnabled())
475 &opt, ev->
pos(),
this);
479 int pressValue =
d->pixelPosToRangeValue(
d->pick(ev->
pos() - sliderRect.
center() + sliderRect.
topLeft()));
480 d->pressValue = pressValue;
481 if (pressValue >
d->value)
483 else if (pressValue < d->
value)
517 int newPosition =
d->pixelPosToRangeValue(
d->pick(ev->
pos()) -
d->clickOffset);
553 const int SliderLength = 84, TickSpace = 5;
561 int w = thick, h = SliderLength;
604 d->resetLayoutItemMargins();
611 return d_func()->tickPosition;
651 d_func()->tickInterval =
qMax(0, ts);
657 return d_func()->tickInterval;
The QPainter class performs low-level painting on widgets and other paint devices.
int pick(const QPoint &pt) const
SubControl
This enum describes the available sub controls.
#define QT_END_NAMESPACE
This macro expands to.
int sliderValue
the value of the slider
QStyle::SubControl hoverControl
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
void setTickPosition(TickPosition position)
QStyle::State state
the style flags that are used when drawing the control
bool event(QEvent *e)
Reimplemented Function
friend Q_GUI_EXPORT QStyleOptionSlider qt_qsliderStyleOption(QSlider *slider)
Returns the style option for slider.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QHoverEvent class contains parameters that describe a mouse event.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int tickInterval
the interval that should be drawn between tick marks
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
int width() const
Returns the width of the rectangle.
void triggerAction(SliderAction action)
Triggers a slider action.
QSlider::TickPosition tickPosition
the position of the slider's tick marks, if any
QSize minimumSizeHint() const
Reimplemented Function
TickPosition
This enum specifies where the tick marks are to be drawn relative to the slider's groove and the hand...
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
QAbstractSlider(QWidget *parent=0)
Constructs an abstract slider.
QStyle::SubControl newHoverControl(const QPoint &pos)
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
void setHeight(int h)
Sets the height to the given height.
void mouseReleaseEvent(QMouseEvent *ev)
Reimplemented Function
void mouseMoveEvent(QMouseEvent *ev)
Reimplemented Function
QStyle::SubControl pressedControl
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
void setObjectName(const QString &name)
void setWidth(int w)
Sets the width to the given width.
void setTickInterval(int ti)
bool upsideDown
the slider control orientation
#define QT_BEGIN_NAMESPACE
This macro expands to.
QSize sizeHint() const
Reimplemented Function
void initFrom(const QWidget *w)
TickPosition tickPosition() const
Qt::Orientation orientation() const
int pixelPosToRangeValue(int pos) const
int sliderPosition
the position of the slider handle
The QSlider widget provides a vertical or horizontal slider.
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
Qt::MouseButton button() const
Returns the button that caused the event.
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
The QMouseEvent class contains parameters that describe a mouse event.
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
QPoint center() const
Returns the center point of the rectangle.
int maximum
the maximum value for the slider
#define Q_DECLARE_PUBLIC(Class)
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
int right() const
Returns the x-coordinate of the rectangle's right edge.
int y() const
Returns the y-coordinate of the rectangle's top edge.
QSlider(QWidget *parent=0)
Constructs a vertical slider with the given parent.
int minimum
the minimum value for the slider
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
The QPoint class defines a point in the plane using integer precision.
void setSliderPosition(int)
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
The QRect class defines a rectangle in the plane using integer precision.
The QAbstractSlider class provides an integer value within a range.
void resetLayoutItemMargins()
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=0) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
int y() const
Returns the y coordinate of this point.
Qt::Orientation orientation
the slider's orientation (horizontal or vertical)
void initStyleOption(QStyleOptionSlider *option) const
Initialize option with the values from this QSlider.
void mousePressEvent(QMouseEvent *ev)
Reimplemented Function
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
int pageStep
the size of the page step of the slider
QSlider::TickPosition tickPosition
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
int singleStep
the size of the single step of the slider
void paintEvent(QPaintEvent *ev)
Reimplemented Function
The QSize class defines the size of a two-dimensional object using integer point precision.
int x() const
Returns the x coordinate of this point.
bool updateHoverControl(const QPoint &pos)
Qt::Orientation orientation
The QPaintEvent class contains event parameters for paint events.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
static int sliderValueFromPosition(int min, int max, int pos, int space, bool upsideDown=false)
Converts the given pixel position to a logical value.
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...
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
~QSlider()
Destroys this slider.
Qt::Orientation orientation
the orientation of the slider
bool event(QEvent *event)
Reimplemented Function
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.