Qt 4.8
qscrollbar.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qapplication.h"
43 #include "qcursor.h"
44 #include "qevent.h"
45 #include "qpainter.h"
46 #include "qscrollbar.h"
47 #include "qstyle.h"
48 #include "qstyleoption.h"
49 #include "qmenu.h"
50 #include <QtCore/qelapsedtimer.h>
51 
52 #ifndef QT_NO_SCROLLBAR
53 
54 #ifndef QT_NO_ACCESSIBILITY
55 #include "qaccessible.h"
56 #endif
57 #include <limits.h>
58 #include "qabstractslider_p.h"
59 
61 
207 {
209 public:
212 
214 
215  void activateControl(uint control, int threshold = 500);
216  void stopRepeatAction();
217  int pixelPosToRangeValue(int pos) const;
218  void init();
219  bool updateHoverControl(const QPoint &pos);
221 
224 };
225 
227 {
228  Q_Q(QScrollBar);
229  QRect lastHoverRect = hoverRect;
230  QStyle::SubControl lastHoverControl = hoverControl;
231  bool doesHover = q->testAttribute(Qt::WA_Hover);
232  if (lastHoverControl != newHoverControl(pos) && doesHover) {
233  q->update(lastHoverRect);
234  q->update(hoverRect);
235  return true;
236  }
237  return !doesHover;
238 }
239 
241 {
242  Q_Q(QScrollBar);
243  QStyleOptionSlider opt;
244  q->initStyleOption(&opt);
246  hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, pos, q);
248  hoverRect = QRect();
249  else
250  hoverRect = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, hoverControl, q);
251  return hoverControl;
252 }
253 
254 void QScrollBarPrivate::activateControl(uint control, int threshold)
255 {
257  switch (control) {
260  break;
263  break;
266  break;
269  break;
272  break;
275  break;
276  default:
277  break;
278  }
279 
280  if (action) {
281  q_func()->setRepeatAction(action, threshold);
282  q_func()->triggerAction(action);
283  }
284 }
285 
287 {
288  Q_Q(QScrollBar);
290  q->setRepeatAction(QAbstractSlider::SliderNoAction);
292 
293  if (tmp == QStyle::SC_ScrollBarSlider)
294  q->setSliderDown(false);
295 
296  QStyleOptionSlider opt;
297  q->initStyleOption(&opt);
298  q->repaint(q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, tmp, q));
299 }
300 
309 {
310  if (!option)
311  return;
312 
313  Q_D(const QScrollBar);
314  option->initFrom(this);
315  option->subControls = QStyle::SC_None;
317  option->orientation = d->orientation;
318  option->minimum = d->minimum;
319  option->maximum = d->maximum;
320  option->sliderPosition = d->position;
321  option->sliderValue = d->value;
322  option->singleStep = d->singleStep;
323  option->pageStep = d->pageStep;
324  option->upsideDown = d->invertedAppearance;
325  if (d->orientation == Qt::Horizontal)
326  option->state |= QStyle::State_Horizontal;
327 }
328 
329 
330 #define HORIZONTAL (d_func()->orientation == Qt::Horizontal)
331 #define VERTICAL !HORIZONTAL
332 
345  : QAbstractSlider(*new QScrollBarPrivate, parent)
346 {
347  d_func()->orientation = Qt::Vertical;
348  d_func()->init();
349 }
350 
363  : QAbstractSlider(*new QScrollBarPrivate, parent)
364 {
365  d_func()->orientation = orientation;
366  d_func()->init();
367 }
368 
369 
370 #ifdef QT3_SUPPORT
371 
376  : QAbstractSlider(*new QScrollBarPrivate, parent)
377 {
379  d_func()->orientation = Qt::Vertical;
380  d_func()->init();
381 }
382 
388  : QAbstractSlider(*new QScrollBarPrivate, parent)
389 {
391  d_func()->orientation = orientation;
392  d_func()->init();
393 }
394 
399 QScrollBar::QScrollBar(int minimum, int maximum, int lineStep, int pageStep,
401  QWidget *parent, const char *name)
402  : QAbstractSlider(*new QScrollBarPrivate, parent)
403 {
404  Q_D(QScrollBar);
406  d->minimum = minimum;
407  d->maximum = maximum;
408  d->singleStep = lineStep;
409  d->pageStep = pageStep;
410  d->value = value;
411  d->orientation = orientation;
412  d->init();
413 }
414 #endif // QT3_SUPPORT
415 
420 {
421 }
422 
424 {
425  Q_Q(QScrollBar);
426  invertedControls = true;
427  pressedControl = hoverControl = QStyle::SC_None;
428  pointerOutsidePressedControl = false;
429  q->setFocusPolicy(Qt::NoFocus);
431  if (orientation == Qt::Vertical)
432  sp.transpose();
433  q->setSizePolicy(sp);
434  q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
435  q->setAttribute(Qt::WA_OpaquePaintEvent);
436 
437 #if !defined(QT_NO_CONTEXTMENU) && defined(Q_WS_WINCE)
438  if (!q->style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, q)) {
439  q->setContextMenuPolicy(Qt::PreventContextMenu);
440  }
441 #endif
442 }
443 
444 #ifndef QT_NO_CONTEXTMENU
445 
447 {
450  return ;
451  }
452 
453 #ifndef QT_NO_MENU
454  bool horiz = HORIZONTAL;
455  QPointer<QMenu> menu = new QMenu(this);
456  QAction *actScrollHere = menu->addAction(tr("Scroll here"));
457  menu->addSeparator();
458  QAction *actScrollTop = menu->addAction(horiz ? tr("Left edge") : tr("Top"));
459  QAction *actScrollBottom = menu->addAction(horiz ? tr("Right edge") : tr("Bottom"));
460  menu->addSeparator();
461  QAction *actPageUp = menu->addAction(horiz ? tr("Page left") : tr("Page up"));
462  QAction *actPageDn = menu->addAction(horiz ? tr("Page right") : tr("Page down"));
463  menu->addSeparator();
464  QAction *actScrollUp = menu->addAction(horiz ? tr("Scroll left") : tr("Scroll up"));
465  QAction *actScrollDn = menu->addAction(horiz ? tr("Scroll right") : tr("Scroll down"));
466  QAction *actionSelected = menu->exec(event->globalPos());
467  delete menu;
468  if (actionSelected == 0)
469  /* do nothing */ ;
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)
484 #endif // QT_NO_MENU
485 }
486 #endif // QT_NO_CONTEXTMENU
487 
488 
491 {
492  ensurePolished();
493  QStyleOptionSlider opt;
494  initStyleOption(&opt);
495 
496  int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent, &opt, this);
497  int scrollBarSliderMin = style()->pixelMetric(QStyle::PM_ScrollBarSliderMin, &opt, this);
498  QSize size;
499  if (opt.orientation == Qt::Horizontal)
500  size = QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent);
501  else
502  size = QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin);
503 
504  return style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this)
506  }
507 
510 {
512 }
513 
518 {
519  switch(event->type()) {
520  case QEvent::HoverEnter:
521  case QEvent::HoverLeave:
522  case QEvent::HoverMove:
523  if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
524  d_func()->updateHoverControl(he->pos());
525  break;
526 #ifndef QT_NO_WHEELEVENT
527  case QEvent::Wheel: {
528  event->ignore();
529  // override wheel event without adding virtual function override
530  if (!isEnabled()) // don't scroll when disabled [QTBUG-27308]
531  return false; // normally prevented in QWidget::event()
532  QWheelEvent *ev = static_cast<QWheelEvent *>(event);
533  int delta = ev->delta();
534  // scrollbar is a special case - in vertical mode it reaches minimum
535  // value in the upper position, however QSlider's minimum value is on
536  // the bottom. So we need to invert a value, but since the scrollbar is
537  // inverted by default, we need to inverse the delta value for the
538  // horizontal orientation.
539  if (ev->orientation() == Qt::Horizontal)
540  delta = -delta;
541  Q_D(QScrollBar);
542  if (d->scrollByDelta(ev->orientation(), ev->modifiers(), delta))
543  event->accept();
544  return true;
545  }
546 #endif
547  default:
548  break;
549  }
550  return QAbstractSlider::event(event);
551 }
552 
557 {
558  Q_D(QScrollBar);
559  QPainter p(this);
560  QStyleOptionSlider opt;
561  initStyleOption(&opt);
563  if (d->pressedControl) {
564  opt.activeSubControls = (QStyle::SubControl)d->pressedControl;
565  if (!d->pointerOutsidePressedControl)
567  } else {
568  opt.activeSubControls = (QStyle::SubControl)d->hoverControl;
569  }
570  style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, &p, this);
571 }
572 
577 {
578  Q_D(QScrollBar);
579 
580  if (d->repeatActionTimer.isActive())
581  d->stopRepeatAction();
582 
584  0, this);
585  QStyleOptionSlider opt;
586  initStyleOption(&opt);
587 
588  if (d->maximum == d->minimum // no range
589  || (e->buttons() & (~e->button())) // another button was clicked before
590  || !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MidButton)))
591  return;
592 
593  d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this);
594  d->pointerOutsidePressedControl = false;
595 
598  QPoint click = e->pos();
599  QPoint pressValue = click - sr.center() + sr.topLeft();
600  d->pressValue = d->orientation == Qt::Horizontal ? d->pixelPosToRangeValue(pressValue.x()) :
601  d->pixelPosToRangeValue(pressValue.y());
602  if (d->pressedControl == QStyle::SC_ScrollBarSlider) {
603  d->clickOffset = HORIZONTAL ? (click.x()-sr.x()) : (click.y()-sr.y());
604  d->snapBackPosition = d->position;
605  }
606 
607  if ((d->pressedControl == QStyle::SC_ScrollBarAddPage
608  || d->pressedControl == QStyle::SC_ScrollBarSubPage)
609  && ((midButtonAbsPos && e->button() == Qt::MidButton)
611  && e->button() == Qt::LeftButton))) {
612  int sliderLength = HORIZONTAL ? sr.width() : sr.height();
613  setSliderPosition(d->pixelPosToRangeValue((HORIZONTAL ? e->pos().x()
614  : e->pos().y()) - sliderLength / 2));
615  d->pressedControl = QStyle::SC_ScrollBarSlider;
616  d->clickOffset = sliderLength / 2;
617  }
618  const int initialDelay = 500; // default threshold
619  d->activateControl(d->pressedControl, initialDelay);
620  QElapsedTimer time;
621  time.start();
622  repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
623  if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) {
624  // It took more than 500ms (the initial timer delay) to process the repaint(), we
625  // therefore need to restart the timer in case we have a pending mouse release event;
626  // otherwise we'll get a timer event right before the release event,
627  // causing the repeat action to be invoked twice on a single mouse click.
628  // 50ms is the default repeat time (see activateControl/setRepeatAction).
629  d->repeatActionTimer.start(50, this);
630  }
631  if (d->pressedControl == QStyle::SC_ScrollBarSlider)
632  setSliderDown(true);
633 }
634 
635 
640 {
641  Q_D(QScrollBar);
642  if (!d->pressedControl)
643  return;
644 
645  if (e->buttons() & (~e->button())) // some other button is still pressed
646  return;
647 
648  d->stopRepeatAction();
649 }
650 
651 
656 {
657  Q_D(QScrollBar);
658  if (!d->pressedControl)
659  return;
660 
661  QStyleOptionSlider opt;
662  initStyleOption(&opt);
663  if (!(e->buttons() & Qt::LeftButton
664  || ((e->buttons() & Qt::MidButton)
666  return;
667 
668  if (d->pressedControl == QStyle::SC_ScrollBarSlider) {
669  QPoint click = e->pos();
670  int newPosition = d->pixelPosToRangeValue((HORIZONTAL ? click.x() : click.y()) -d->clickOffset);
671  int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this);
672  if (m >= 0) {
673  QRect r = rect();
674  r.adjust(-m, -m, m, m);
675  if (! r.contains(e->pos()))
676  newPosition = d->snapBackPosition;
677  }
678  setSliderPosition(newPosition);
680 
682  && d->pressedControl & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)) {
684  if (newSc == d->pressedControl && !d->pointerOutsidePressedControl)
685  return; // nothing to do
687  d->pointerOutsidePressedControl = false;
688  QRect scRect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, newSc, this);
689  scRect |= style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this);
690  d->pressedControl = newSc;
691  d->activateControl(d->pressedControl, 0);
692  update(scRect);
693  return;
694  }
695  }
696 
697  // stop scrolling when the mouse pointer leaves a control
698  // similar to push buttons
699  QRect pr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this);
700  if (pr.contains(e->pos()) == d->pointerOutsidePressedControl) {
701  if ((d->pointerOutsidePressedControl = !d->pointerOutsidePressedControl)) {
702  d->pointerOutsidePressedControl = true;
704  repaint(pr);
705  } else {
706  d->activateControl(d->pressedControl);
707  }
708  }
709  }
710 }
711 
712 
714 {
715  Q_Q(const QScrollBar);
716  QStyleOptionSlider opt;
717  q->initStyleOption(&opt);
718  QRect gr = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
720  QRect sr = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
722  int sliderMin, sliderMax, sliderLength;
723 
724  if (orientation == Qt::Horizontal) {
725  sliderLength = sr.width();
726  sliderMin = gr.x();
727  sliderMax = gr.right() - sliderLength + 1;
728  if (q->layoutDirection() == Qt::RightToLeft)
729  opt.upsideDown = !opt.upsideDown;
730  } else {
731  sliderLength = sr.height();
732  sliderMin = gr.y();
733  sliderMax = gr.bottom() - sliderLength + 1;
734  }
735 
736  return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin,
737  sliderMax - sliderMin, opt.upsideDown);
738 }
739 
743 {
744  Q_D(QScrollBar);
745  if (d->pressedControl) {
746  d->pressedControl = QStyle::SC_None;
748  }
749 }
750 
767 {
768  QStyleOptionSlider opt;
769  scrollbar->initStyleOption(&opt);
770  return opt;
771 }
772 
774 
775 #endif // QT_NO_SCROLLBAR
QPoint pos() const
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
QStyle::SubControl newHoverControl(const QPoint &pos)
Definition: qscrollbar.cpp:240
void mouseReleaseEvent(QMouseEvent *)
Reimplemented Function
Definition: qscrollbar.cpp:639
void contextMenuEvent(QContextMenuEvent *)
Reimplemented Function
Definition: qscrollbar.cpp:446
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int sliderValue
the value of the slider
Definition: qstyleoption.h:714
QSize size() const
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
virtual void sliderChange(SliderChange change)
Reimplement this virtual function to track slider changes such as SliderRangeChange ...
~QScrollBar()
Destroys the scroll bar.
Definition: qscrollbar.cpp:419
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
bool event(QEvent *e)
Reimplemented Function
int minimum() const
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
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...
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
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.
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QHoverEvent class contains parameters that describe a mouse event.
Definition: qevent.h:125
void initStyleOption(QStyleOptionSlider *option) const
Initialize option with the values from this QScrollBar.
Definition: qscrollbar.cpp:308
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
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...
bool event(QEvent *event)
Reimplemented Function
Definition: qscrollbar.cpp:517
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
void paintEvent(QPaintEvent *)
Reimplemented Function
Definition: qscrollbar.cpp:556
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void triggerAction(SliderAction action)
Triggers a slider action.
void mouseMoveEvent(QMouseEvent *)
Reimplemented Function
Definition: qscrollbar.cpp:655
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...
Definition: qstyleoption.h:694
QAbstractSlider(QWidget *parent=0)
Constructs an abstract slider.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
bool updateHoverControl(const QPoint &pos)
Definition: qscrollbar.cpp:226
#define Q_D(Class)
Definition: qglobal.h:2482
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
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...
Definition: qevent.h:95
QStyle * style() const
Definition: qwidget.cpp:2742
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
bool upsideDown
the slider control orientation
Definition: qstyleoption.h:712
The QScrollBar widget provides a vertical or horizontal scroll bar.
Definition: qscrollbar.h:59
int value() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
const char * name
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QStyle::SubControl hoverControl
Definition: qscrollbar.cpp:222
const char * styleHint(const QFontDef &request)
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
QAction * addSeparator()
This convenience function creates a new separator action, i.e.
Definition: qmenu.cpp:1583
unsigned int uint
Definition: qglobal.h:996
Qt::Orientation orientation() const
int sliderPosition
the position of the slider handle
Definition: qstyleoption.h:713
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...
QStyle::SubControl pressedControl
Definition: qscrollbar.cpp:210
Qt::Orientation orientation() const
Returns the wheel&#39;s orientation.
Definition: qevent.h:159
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
QRect rect() const
void setSliderDown(bool)
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...
Definition: qrect.cpp:1101
bool isEnabled() const
Definition: qwidget.h:948
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
void repaint()
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the ...
Definition: qwidget.cpp:10761
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...
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
virtual void contextMenuEvent(QContextMenuEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition: qwidget.cpp:9645
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
int maximum
the maximum value for the slider
Definition: qstyleoption.h:709
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QScrollBar(QWidget *parent=0)
Constructs a vertical scroll bar.
Definition: qscrollbar.cpp:344
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QSize sizeHint() const
Reimplemented Function
Definition: qscrollbar.cpp:490
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
bool pointerOutsidePressedControl
Definition: qscrollbar.cpp:211
int minimum
the minimum value for the slider
Definition: qstyleoption.h:708
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setSliderPosition(int)
void mousePressEvent(QMouseEvent *)
Reimplemented Function
Definition: qscrollbar.cpp:576
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QAbstractSlider class provides an integer value within a range.
friend Q_GUI_EXPORT QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar *scrollBar)
Returns the style option for scroll bar.
Definition: qscrollbar.cpp:766
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...
void transpose()
Definition: qsizepolicy.h:229
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
Qt::Orientation orientation
the slider&#39;s orientation (horizontal or vertical)
Definition: qstyleoption.h:707
QObject * parent
Definition: qobject.h:92
return(isPopup||isToolTip)
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
int pageStep
the size of the page step of the slider
Definition: qstyleoption.h:716
int singleStep
the size of the single step of the slider
Definition: qstyleoption.h:715
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
int pixelPosToRangeValue(int pos) const
Definition: qscrollbar.cpp:713
void activateControl(uint control, int threshold=500)
Definition: qscrollbar.cpp:254
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
int maximum() const
Orientation
Definition: qnamespace.h:174
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
int pageStep() const
static int sliderValueFromPosition(int min, int max, int pos, int space, bool upsideDown=false)
Converts the given pixel position to a logical value.
Definition: qstyle.cpp:2222
void sliderChange(SliderChange change)
Reimplement this virtual function to track slider changes such as SliderRangeChange ...
Definition: qscrollbar.cpp:509
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.
Definition: qstyleoption.h:693
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
Qt::Orientation orientation
the orientation of the slider
void hideEvent(QHideEvent *)
Reimplemented Function
Definition: qscrollbar.cpp:742
#define HORIZONTAL
Definition: qscrollbar.cpp:330
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288