50 #include <QtCore/qelapsedtimer.h> 52 #ifndef QT_NO_SCROLLBAR 54 #ifndef QT_NO_ACCESSIBILITY 233 q->update(lastHoverRect);
244 q->initStyleOption(&opt);
281 q_func()->setRepeatAction(action, threshold);
282 q_func()->triggerAction(action);
294 q->setSliderDown(
false);
297 q->initStyleOption(&opt);
330 #define HORIZONTAL (d_func()->orientation == Qt::Horizontal) 331 #define VERTICAL !HORIZONTAL 408 d->singleStep = lineStep;
414 #endif // QT3_SUPPORT 428 pointerOutsidePressedControl =
false;
433 q->setSizePolicy(sp);
437 #if !defined(QT_NO_CONTEXTMENU) && defined(Q_WS_WINCE) 444 #ifndef QT_NO_CONTEXTMENU 468 if (actionSelected == 0)
470 else if (actionSelected == actScrollHere)
471 setValue(d_func()->pixelPosToRangeValue(horiz ? event->
pos().
x() :
event->pos().y()));
472 else if (actionSelected == actScrollTop)
474 else if (actionSelected == actScrollBottom)
476 else if (actionSelected == actPageUp)
478 else if (actionSelected == actPageDn)
480 else if (actionSelected == actScrollUp)
482 else if (actionSelected == actScrollDn)
486 #endif // QT_NO_CONTEXTMENU 500 size =
QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent);
502 size =
QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin);
519 switch(event->
type()) {
523 if (
const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
524 d_func()->updateHoverControl(he->pos());
526 #ifndef QT_NO_WHEELEVENT 533 int delta = ev->
delta();
563 if (
d->pressedControl) {
565 if (!
d->pointerOutsidePressedControl)
580 if (
d->repeatActionTimer.isActive())
581 d->stopRepeatAction();
588 if (
d->maximum ==
d->minimum
594 d->pointerOutsidePressedControl =
false;
600 d->pressValue =
d->orientation ==
Qt::Horizontal ?
d->pixelPosToRangeValue(pressValue.
x()) :
601 d->pixelPosToRangeValue(pressValue.
y());
604 d->snapBackPosition =
d->position;
614 : e->
pos().
y()) - sliderLength / 2));
616 d->clickOffset = sliderLength / 2;
618 const int initialDelay = 500;
619 d->activateControl(
d->pressedControl, initialDelay);
623 if (time.
elapsed() >= initialDelay &&
d->repeatActionTimer.isActive()) {
629 d->repeatActionTimer.start(50,
this);
642 if (!
d->pressedControl)
648 d->stopRepeatAction();
658 if (!
d->pressedControl)
670 int newPosition =
d->pixelPosToRangeValue((
HORIZONTAL ? click.
x() : click.
y()) -
d->clickOffset);
676 newPosition =
d->snapBackPosition;
684 if (newSc ==
d->pressedControl && !
d->pointerOutsidePressedControl)
687 d->pointerOutsidePressedControl =
false;
690 d->pressedControl = newSc;
691 d->activateControl(
d->pressedControl, 0);
700 if (pr.
contains(e->
pos()) ==
d->pointerOutsidePressedControl) {
701 if ((
d->pointerOutsidePressedControl = !
d->pointerOutsidePressedControl)) {
702 d->pointerOutsidePressedControl =
true;
706 d->activateControl(
d->pressedControl);
717 q->initStyleOption(&opt);
722 int sliderMin, sliderMax, sliderLength;
725 sliderLength = sr.
width();
727 sliderMax = gr.
right() - sliderLength + 1;
731 sliderLength = sr.
height();
733 sliderMax = gr.
bottom() - sliderLength + 1;
745 if (
d->pressedControl) {
775 #endif // QT_NO_SCROLLBAR
The QPainter class performs low-level painting on widgets and other paint devices.
SubControl
This enum describes the available sub controls.
#define QT_END_NAMESPACE
This macro expands to.
int sliderValue
the value of the slider
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
virtual void sliderChange(SliderChange change)
Reimplement this virtual function to track slider changes such as SliderRangeChange ...
QStyle::State state
the style flags that are used when drawing the control
bool event(QEvent *e)
Reimplemented Function
The QWheelEvent class contains parameters that describe a wheel event.
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.
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...
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.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
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.
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QElapsedTimer class provides a fast way to calculate elapsed times.
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
void setObjectName(const QString &name)
bool upsideDown
the slider control orientation
#define QT_BEGIN_NAMESPACE
This macro expands to.
void initFrom(const QWidget *w)
The QHideEvent class provides an event which is sent after a widget is hidden.
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
const char * styleHint(const QFontDef &request)
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Qt::Orientation orientation() const
int sliderPosition
the position of the slider handle
bool invertedControls() const
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::Orientation orientation() const
Returns the wheel's orientation.
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.
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.
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)
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
The QAbstractSlider class provides an integer value within a range.
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)
return(isPopup||isToolTip)
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
int singleStep
the size of the single step of the slider
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.
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 start()
Starts this timer.
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.
The QAction class provides an abstract user interface action that can be inserted into widgets...
Qt::Orientation orientation
the orientation of the slider
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.