Qt 4.8
qabstractscrollarea.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 "qabstractscrollarea.h"
43 
44 #ifndef QT_NO_SCROLLAREA
45 
46 #include "qscrollbar.h"
47 #include "qapplication.h"
48 #include "qstyle.h"
49 #include "qstyleoption.h"
50 #include "qevent.h"
51 #include "qdebug.h"
52 #include "qboxlayout.h"
53 #include "qpainter.h"
54 #include "qmargins.h"
55 
56 #include "qabstractscrollarea_p.h"
57 #include <qwidget.h>
58 
59 #include <private/qapplication_p.h>
60 
61 #ifdef Q_WS_MAC
62 #include <private/qt_mac_p.h>
63 #include <private/qt_cocoa_helpers_mac_p.h>
64 #endif
65 
67 
162  :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
163  viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
164  xoffset(0), yoffset(0), viewportFilter(0)
165 #ifdef Q_WS_WIN
166  , singleFingerPanEnabled(false)
167 #endif
168 {
169 }
170 
172  :QWidget(parent), scrollBar(new QScrollBar(orientation, this)),
173  layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)),
174  orientation(orientation)
175 {
176  setLayout(layout);
177  layout->setMargin(0);
178  layout->setSpacing(0);
180 }
181 
189 {
190  QSizePolicy policy = widget->sizePolicy();
191  if (orientation == Qt::Vertical)
193  else
195  widget->setSizePolicy(policy);
196  widget->setParent(this);
197 
198  const int insertIndex = (position & LogicalLeft) ? 0 : scrollBarLayoutIndex() + 1;
199  layout->insertWidget(insertIndex, widget);
200 }
201 
210 {
211  QWidgetList list;
212  const int scrollBarIndex = scrollBarLayoutIndex();
213  if (position == LogicalLeft) {
214  for (int i = 0; i < scrollBarIndex; ++i)
215  list.append(layout->itemAt(i)->widget());
216  } else if (position == LogicalRight) {
217  const int layoutItemCount = layout->count();
218  for (int i = scrollBarIndex + 1; i < layoutItemCount; ++i)
219  list.append(layout->itemAt(i)->widget());
220  }
221  return list;
222 }
223 
234 {
235  const int layoutItemCount = layout->count();
236  for (int i = 0; i < layoutItemCount; ++i) {
237  if (qobject_cast<QScrollBar *>(layout->itemAt(i)->widget()))
238  return i;
239  }
240  return -1;
241 }
242 
247 {
249 
250  QAbstractScrollAreaScrollBarContainer *container = scrollBarContainers[orientation];
251  bool horizontal = (orientation == Qt::Horizontal);
252  QScrollBar *oldBar = horizontal ? hbar : vbar;
253  if (horizontal)
254  hbar = scrollBar;
255  else
256  vbar = scrollBar;
257  scrollBar->setParent(container);
258  container->scrollBar = scrollBar;
259  container->layout->removeWidget(oldBar);
260  container->layout->insertWidget(0, scrollBar);
261  scrollBar->setVisible(oldBar->isVisibleTo(container));
262  scrollBar->setInvertedAppearance(oldBar->invertedAppearance());
263  scrollBar->setInvertedControls(oldBar->invertedControls());
264  scrollBar->setRange(oldBar->minimum(), oldBar->maximum());
265  scrollBar->setOrientation(oldBar->orientation());
266  scrollBar->setPageStep(oldBar->pageStep());
267  scrollBar->setSingleStep(oldBar->singleStep());
268  scrollBar->setSliderDown(oldBar->isSliderDown());
269  scrollBar->setSliderPosition(oldBar->sliderPosition());
270  scrollBar->setTracking(oldBar->hasTracking());
271  scrollBar->setValue(oldBar->value());
272  delete oldBar;
273 
274  QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
275  q, horizontal ? SLOT(_q_hslide(int)) : SLOT(_q_vslide(int)));
276  QObject::connect(scrollBar, SIGNAL(rangeChanged(int,int)),
277  q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
278 }
279 
281 {
283  viewport = new QWidget(q);
284  viewport->setObjectName(QLatin1String("qt_scrollarea_viewport"));
285  viewport->setBackgroundRole(QPalette::Base);
286  viewport->setAutoFillBackground(true);
288  scrollBarContainers[Qt::Horizontal]->setObjectName(QLatin1String("qt_scrollarea_hcontainer"));
289  hbar = scrollBarContainers[Qt::Horizontal]->scrollBar;
290  hbar->setRange(0,0);
291  scrollBarContainers[Qt::Horizontal]->setVisible(false);
292  QObject::connect(hbar, SIGNAL(valueChanged(int)), q, SLOT(_q_hslide(int)));
293  QObject::connect(hbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
294  scrollBarContainers[Qt::Vertical] = new QAbstractScrollAreaScrollBarContainer(Qt::Vertical, q);
295  scrollBarContainers[Qt::Vertical]->setObjectName(QLatin1String("qt_scrollarea_vcontainer"));
296  vbar = scrollBarContainers[Qt::Vertical]->scrollBar;
297  vbar->setRange(0,0);
298  scrollBarContainers[Qt::Vertical]->setVisible(false);
299  QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));
300  QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
301  viewportFilter.reset(new QAbstractScrollAreaFilter(this));
302  viewport->installEventFilter(viewportFilter.data());
303  viewport->setFocusProxy(q);
304  q->setFocusPolicy(Qt::WheelFocus);
305  q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
307  layoutChildren();
308 #ifndef Q_WS_MAC
309 #ifndef QT_NO_GESTURES
310  viewport->grabGesture(Qt::PanGesture);
311 #endif
312 #endif
313 }
314 
315 #ifdef Q_WS_WIN
317 {
318  singleFingerPanEnabled = on;
319  QWidgetPrivate *dd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(viewport));
320  if (dd)
321  dd->winSetupGestures();
322 }
323 #endif // Q_WS_WIN
324 
326 {
328  bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
329  || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
330 
331  bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
332  || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
333 
334 #ifdef Q_WS_MAC
335  QWidget * const window = q->window();
336 
337  // Use small scroll bars for tool windows, to match the native size grip.
338  bool hbarIsSmall = hbar->testAttribute(Qt::WA_MacSmallSize);
339  bool vbarIsSmall = vbar->testAttribute(Qt::WA_MacSmallSize);
340  const Qt::WindowType windowType = window->windowType();
341  if (windowType == Qt::Tool) {
342  if (!hbarIsSmall) {
343  hbar->setAttribute(Qt::WA_MacMiniSize, false);
344  hbar->setAttribute(Qt::WA_MacNormalSize, false);
345  hbar->setAttribute(Qt::WA_MacSmallSize, true);
346  }
347  if (!vbarIsSmall) {
348  vbar->setAttribute(Qt::WA_MacMiniSize, false);
349  vbar->setAttribute(Qt::WA_MacNormalSize, false);
350  vbar->setAttribute(Qt::WA_MacSmallSize, true);
351  }
352  } else {
353  if (hbarIsSmall) {
354  hbar->setAttribute(Qt::WA_MacMiniSize, false);
355  hbar->setAttribute(Qt::WA_MacNormalSize, false);
356  hbar->setAttribute(Qt::WA_MacSmallSize, false);
357  }
358  if (vbarIsSmall) {
359  vbar->setAttribute(Qt::WA_MacMiniSize, false);
360  vbar->setAttribute(Qt::WA_MacNormalSize, false);
361  vbar->setAttribute(Qt::WA_MacSmallSize, false);
362  }
363  }
364 #endif
365 
366  const int hsbExt = hbar->sizeHint().height();
367  const int vsbExt = vbar->sizeHint().width();
368  const QPoint extPoint(vsbExt, hsbExt);
369  const QSize extSize(vsbExt, hsbExt);
370 
371  const QRect widgetRect = q->rect();
372  QStyleOption opt(0);
373  opt.init(q);
374 
375  const bool hasCornerWidget = (cornerWidget != 0);
376 
377 // If the scroll bars are at the very right and bottom of the window we
378 // move their positions to be aligned with the size grip.
379 #ifdef Q_WS_MAC
380  // Check if a native sizegrip is present.
381  bool hasMacReverseSizeGrip = false;
382  bool hasMacSizeGrip = false;
383  bool nativeGripPresent = false;
384  if (q->testAttribute(Qt::WA_WState_Created))
385  nativeGripPresent = qt_mac_checkForNativeSizeGrip(q);
386 
387  if (nativeGripPresent) {
388  // Look for a native size grip at the visual window bottom right and at the
389  // absolute window bottom right. In reverse mode, the native size grip does not
390  // swich side, so we need to check if it is on the "wrong side".
391  const QPoint scrollAreaBottomRight = q->mapTo(window, widgetRect.bottomRight() - QPoint(frameWidth, frameWidth));
392  const QPoint windowBottomRight = window->rect().bottomRight();
393  const QPoint visualWindowBottomRight = QStyle::visualPos(opt.direction, opt.rect, windowBottomRight);
394  const QPoint offset = windowBottomRight - scrollAreaBottomRight;
395  const QPoint visualOffset = visualWindowBottomRight - scrollAreaBottomRight;
396  hasMacSizeGrip = (visualOffset.manhattanLength() < vsbExt);
397  hasMacReverseSizeGrip = (hasMacSizeGrip == false && (offset.manhattanLength() < hsbExt));
398  }
399 #endif
400 
401  QPoint cornerOffset(needv ? vsbExt : 0, needh ? hsbExt : 0);
402  QRect controlsRect;
403  QRect viewportRect;
404 
405  // In FrameOnlyAroundContents mode the frame is drawn between the controls and
406  // the viewport, else the frame rect is equal to the widget rect.
407  if ((frameStyle != QFrame::NoFrame) &&
408  q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
409  controlsRect = widgetRect;
410  const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);
411  const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0);
412  QRect frameRect = widgetRect;
413  frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y());
414  q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, frameRect));
415  // The frame rect needs to be in logical coords, however we need to flip
416  // the contentsRect back before passing it on to the viewportRect
417  // since the viewportRect has its logical coords calculated later.
418  viewportRect = QStyle::visualRect(opt.direction, opt.rect, q->contentsRect());
419  } else {
420  q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, widgetRect));
421  controlsRect = q->contentsRect();
422  viewportRect = QRect(controlsRect.topLeft(), controlsRect.bottomRight() - cornerOffset);
423  }
424 
425  // If we have a corner widget and are only showing one scroll bar, we need to move it
426  // to make room for the corner widget.
427  if (hasCornerWidget && (needv || needh))
428  cornerOffset = extPoint;
429 
430 #ifdef Q_WS_MAC
431  // Also move the scroll bars if they are covered by the native Mac size grip.
432  if (hasMacSizeGrip)
433  cornerOffset = extPoint;
434 #endif
435 
436  // The corner point is where the scroll bar rects, the corner widget rect and the
437  // viewport rect meets.
438  const QPoint cornerPoint(controlsRect.bottomRight() + QPoint(1, 1) - cornerOffset);
439 
440  // Some styles paints the corner if both scorllbars are showing and there is
441  // no corner widget. Also, on the Mac we paint if there is a native
442  // (transparent) sizegrip in the area where a corner widget would be.
443  if ((needv && needh && hasCornerWidget == false)
444  || ((needv || needh)
445 #ifdef Q_WS_MAC
446  && hasMacSizeGrip
447 #endif
448  )
449  ) {
450  cornerPaintingRect = QStyle::visualRect(opt.direction, opt.rect, QRect(cornerPoint, extSize));
451  } else {
452  cornerPaintingRect = QRect();
453  }
454 
455 #ifdef Q_WS_MAC
456  if (hasMacReverseSizeGrip)
457  reverseCornerPaintingRect = QRect(controlsRect.bottomRight() + QPoint(1, 1) - extPoint, extSize);
458  else
459  reverseCornerPaintingRect = QRect();
460 #endif
461 
462  if (needh) {
463  QRect horizontalScrollBarRect(QPoint(controlsRect.left(), cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom()));
464 #ifdef Q_WS_MAC
465  if (hasMacReverseSizeGrip)
466  horizontalScrollBarRect.adjust(vsbExt, 0, 0, 0);
467 #endif
468  scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect));
469  scrollBarContainers[Qt::Horizontal]->raise();
470  }
471 
472  if (needv) {
473  const QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top()), QPoint(controlsRect.right(), cornerPoint.y() - 1));
474  scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect));
475  scrollBarContainers[Qt::Vertical]->raise();
476  }
477 
478  if (cornerWidget) {
479  const QRect cornerWidgetRect(cornerPoint, controlsRect.bottomRight());
480  cornerWidget->setGeometry(QStyle::visualRect(opt.direction, opt.rect, cornerWidgetRect));
481  }
482 
483  scrollBarContainers[Qt::Horizontal]->setVisible(needh);
484  scrollBarContainers[Qt::Vertical]->setVisible(needv);
485 
486  if (q->isRightToLeft())
487  viewportRect.adjust(right, top, -left, -bottom);
488  else
489  viewportRect.adjust(left, top, -right, -bottom);
490 
491  viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); // resize the viewport last
492 }
493 
503  :QFrame(dd, parent)
504 {
506  QT_TRY {
507  d->init();
508  } QT_CATCH(...) {
509  d->viewportFilter.reset();
510  QT_RETHROW;
511  }
512 }
513 
520  :QFrame(*new QAbstractScrollAreaPrivate, parent)
521 {
523  QT_TRY {
524  d->init();
525  } QT_CATCH(...) {
526  d->viewportFilter.reset();
527  QT_RETHROW;
528  }
529 }
530 
531 
536 {
538  // reset it here, otherwise we'll have a dangling pointer in ~QWidget
539  d->viewportFilter.reset();
540 }
541 
542 
557 {
559  if (widget != d->viewport) {
560  QWidget *oldViewport = d->viewport;
561  if (!widget)
562  widget = new QWidget;
563  d->viewport = widget;
564  d->viewport->setParent(this);
565  d->viewport->setFocusProxy(this);
566  d->viewport->installEventFilter(d->viewportFilter.data());
567 #ifndef Q_WS_MAC
568 #ifndef QT_NO_GESTURES
569  d->viewport->grabGesture(Qt::PanGesture);
570 #endif
571 #endif
572  d->layoutChildren();
573  if (isVisible())
574  d->viewport->show();
575  QMetaObject::invokeMethod(this, "setupViewport", Q_ARG(QWidget *, widget));
576  delete oldViewport;
577  }
578 }
579 
589 {
590  Q_D(const QAbstractScrollArea);
591  return d->viewport;
592 }
593 
594 
599 // ### still thinking about the name
601 {
602  Q_D(const QAbstractScrollArea);
603  int hsbExt = d->hbar->sizeHint().height();
604  int vsbExt = d->vbar->sizeHint().width();
605 
606  int f = 2 * d->frameWidth;
607  QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom);
608  if (d->vbarpolicy == Qt::ScrollBarAlwaysOn)
609  max.rwidth() -= vsbExt;
610  if (d->hbarpolicy == Qt::ScrollBarAlwaysOn)
611  max.rheight() -= hsbExt;
612  return max;
613 }
614 
628 {
629  Q_D(const QAbstractScrollArea);
630  return d->vbarpolicy;
631 }
632 
634 {
636  const Qt::ScrollBarPolicy oldPolicy = d->vbarpolicy;
637  d->vbarpolicy = policy;
638  if (isVisible())
639  d->layoutChildren();
640  if (oldPolicy != d->vbarpolicy)
641  d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);
642 }
643 
644 
651 {
652  Q_D(const QAbstractScrollArea);
653  return d->vbar;
654 }
655 
672 {
674  if (!scrollBar) {
675  qWarning("QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar");
676  return;
677  }
678 
679  d->replaceScrollBar(scrollBar, Qt::Vertical);
680 }
681 
695 {
696  Q_D(const QAbstractScrollArea);
697  return d->hbarpolicy;
698 }
699 
701 {
703  const Qt::ScrollBarPolicy oldPolicy = d->hbarpolicy;
704  d->hbarpolicy = policy;
705  if (isVisible())
706  d->layoutChildren();
707  if (oldPolicy != d->hbarpolicy)
708  d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);
709 }
710 
717 {
718  Q_D(const QAbstractScrollArea);
719  return d->hbar;
720 }
721 
739 {
741  if (!scrollBar) {
742  qWarning("QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar");
743  return;
744  }
745 
746  d->replaceScrollBar(scrollBar, Qt::Horizontal);
747 }
748 
760 {
761  Q_D(const QAbstractScrollArea);
762  return d->cornerWidget;
763 }
764 
795 {
797  QWidget* oldWidget = d->cornerWidget;
798  if (oldWidget != widget) {
799  if (oldWidget)
800  oldWidget->hide();
801  d->cornerWidget = widget;
802 
803  if (widget && widget->parentWidget() != this)
804  widget->setParent(this);
805 
806  d->layoutChildren();
807  if (widget)
808  widget->show();
809  } else {
810  d->cornerWidget = widget;
811  d->layoutChildren();
812  }
813 }
814 
851 {
853 
854  if (widget == 0)
855  return;
856 
858  = ((alignment & Qt::AlignLeft) || (alignment & Qt::AlignRight)) ? Qt::Horizontal : Qt::Vertical;
860  = ((alignment & Qt::AlignRight) || (alignment & Qt::AlignBottom))
862  d->scrollBarContainers[scrollBarOrientation]->addWidget(widget, position);
863  d->layoutChildren();
864  if (isHidden() == false)
865  widget->show();
866 }
867 
879 {
881 
882  QWidgetList list;
883 
884  if (alignment & Qt::AlignLeft)
885  list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
886  if (alignment & Qt::AlignRight)
887  list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
888  if (alignment & Qt::AlignTop)
889  list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
890  if (alignment & Qt::AlignBottom)
891  list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
892 
893  return list;
894 }
895 
910 void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom)
911 {
913  d->left = left;
914  d->top = top;
915  d->right = right;
916  d->bottom = bottom;
917  d->layoutChildren();
918 }
919 
934 {
935  setViewportMargins(margins.left(), margins.top(),
936  margins.right(), margins.bottom());
937 }
938 
952 {
954  switch (e->type()) {
956  // There was a chance that with accessibility client we get an
957  // event before the viewport was created.
958  // Also, in some cases we might get here from QWidget::event() virtual function which is (indirectly) called
959  // from the viewport constructor at the time when the d->viewport is not yet initialized even without any
960  // accessibility client. See qabstractscrollarea autotest for a test case.
961  if (d->viewport)
962  d->viewport->setAcceptDrops(acceptDrops());
963  break;
965  d->viewport->setMouseTracking(hasMouseTracking());
966  break;
967  case QEvent::Resize:
968  d->layoutChildren();
969  break;
970  case QEvent::Paint: {
971  QStyleOption option;
972  option.initFrom(this);
973  if (d->cornerPaintingRect.isValid()) {
974  option.rect = d->cornerPaintingRect;
975  QPainter p(this);
977  }
978 #ifdef Q_WS_MAC
979  if (d->reverseCornerPaintingRect.isValid()) {
980  option.rect = d->reverseCornerPaintingRect;
981  QPainter p(this);
983  }
984 #endif
985  }
987  break;
988 #ifndef QT_NO_CONTEXTMENU
989  case QEvent::ContextMenu:
990  if (static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard)
991  return QFrame::event(e);
992  e->ignore();
993  break;
994 #endif // QT_NO_CONTEXTMENU
998  case QEvent::MouseMove:
999  case QEvent::Wheel:
1000 #ifndef QT_NO_DRAGANDDROP
1001  case QEvent::Drop:
1002  case QEvent::DragEnter:
1003  case QEvent::DragMove:
1004  case QEvent::DragLeave:
1005 #endif
1006  // ignore touch events in case they have been propagated from the viewport
1007  case QEvent::TouchBegin:
1008  case QEvent::TouchUpdate:
1009  case QEvent::TouchEnd:
1010  return false;
1011 #ifndef QT_NO_GESTURES
1012  case QEvent::Gesture:
1013  {
1014  QGestureEvent *ge = static_cast<QGestureEvent *>(e);
1015  QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture));
1016  if (g) {
1017  QScrollBar *hBar = horizontalScrollBar();
1018  QScrollBar *vBar = verticalScrollBar();
1019  QPointF delta = g->delta();
1020  if (!delta.isNull()) {
1022  delta.rx() *= -1;
1023  int newX = hBar->value() - delta.x();
1024  int newY = vBar->value() - delta.y();
1025  hBar->setValue(newX);
1026  vBar->setValue(newY);
1027  }
1028  return true;
1029  }
1030  return false;
1031  }
1032 #endif // QT_NO_GESTURES
1033  case QEvent::StyleChange:
1036  case QEvent::LayoutRequest:
1037  d->layoutChildren();
1038  // fall through
1039  default:
1040  return QFrame::event(e);
1041  }
1042  return true;
1043 }
1044 
1066 {
1067  switch (e->type()) {
1068  case QEvent::Resize:
1069  case QEvent::Paint:
1073  case QEvent::TouchBegin:
1074  case QEvent::TouchUpdate:
1075  case QEvent::TouchEnd:
1076  case QEvent::MouseMove:
1077  case QEvent::ContextMenu:
1078 #ifndef QT_NO_WHEELEVENT
1079  case QEvent::Wheel:
1080 #endif
1081 #ifndef QT_NO_DRAGANDDROP
1082  case QEvent::Drop:
1083  case QEvent::DragEnter:
1084  case QEvent::DragMove:
1085  case QEvent::DragLeave:
1086 #endif
1087  return QFrame::event(e);
1088  case QEvent::LayoutRequest:
1089 #ifndef QT_NO_GESTURES
1090  case QEvent::Gesture:
1092  return event(e);
1093 #endif
1094  default:
1095  break;
1096  }
1097  return false; // let the viewport widget handle the event
1098 }
1099 
1114 {
1115 }
1116 
1128 {
1129 }
1130 
1139 {
1140  e->ignore();
1141 }
1142 
1151 {
1152  e->ignore();
1153 }
1154 
1163 {
1164  e->ignore();
1165 }
1166 
1175 {
1176  e->ignore();
1177 }
1178 
1186 #ifndef QT_NO_WHEELEVENT
1188 {
1190  if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal)
1191  QApplication::sendEvent(d->hbar, e);
1192  else
1193  QApplication::sendEvent(d->vbar, e);
1194 }
1195 #endif
1196 
1197 #ifndef QT_NO_CONTEXTMENU
1198 
1206 {
1207  e->ignore();
1208 }
1209 #endif // QT_NO_CONTEXTMENU
1210 
1217 {
1219  if (false){
1220 #ifndef QT_NO_SHORTCUT
1221  } else if (e == QKeySequence::MoveToPreviousPage) {
1222  d->vbar->triggerAction(QScrollBar::SliderPageStepSub);
1223  } else if (e == QKeySequence::MoveToNextPage) {
1224  d->vbar->triggerAction(QScrollBar::SliderPageStepAdd);
1225 #endif
1226  } else {
1227 #ifdef QT_KEYPAD_NAVIGATION
1228  if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1229  e->ignore();
1230  return;
1231  }
1232 #endif
1233  switch (e->key()) {
1234  case Qt::Key_Up:
1235  d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);
1236  break;
1237  case Qt::Key_Down:
1238  d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);
1239  break;
1240  case Qt::Key_Left:
1241 #ifdef QT_KEYPAD_NAVIGATION
1242  if (QApplication::keypadNavigationEnabled() && hasEditFocus()
1243  && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {
1244  //if we aren't using the hbar or we are already at the leftmost point ignore
1245  e->ignore();
1246  return;
1247  }
1248 #endif
1249  d->hbar->triggerAction(
1252  break;
1253  case Qt::Key_Right:
1254 #ifdef QT_KEYPAD_NAVIGATION
1255  if (QApplication::keypadNavigationEnabled() && hasEditFocus()
1256  && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {
1257  //if we aren't using the hbar or we are already at the rightmost point ignore
1258  e->ignore();
1259  return;
1260  }
1261 #endif
1262  d->hbar->triggerAction(
1264  ? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);
1265  break;
1266  default:
1267  e->ignore();
1268  return;
1269  }
1270  }
1271  e->accept();
1272 }
1273 
1274 
1275 #ifndef QT_NO_DRAGANDDROP
1276 
1285 {
1286 }
1287 
1297 {
1298 }
1299 
1309 {
1310 }
1311 
1321 {
1322 }
1323 
1324 
1325 #endif
1326 
1346 {
1347  viewport()->update();
1348 }
1349 
1351 {
1353  int dx = xoffset - x;
1354  xoffset = x;
1355  q->scrollContentsBy(dx, 0);
1356 }
1357 
1359 {
1361  int dy = yoffset - y;
1362  yoffset = y;
1363  q->scrollContentsBy(0, dy);
1364 }
1365 
1367 {
1368  layoutChildren();
1369 #ifdef Q_WS_WIN
1370  // Need to re-subscribe to gestures as the content changes to make sure we
1371  // enable/disable panning when needed.
1373  if (dd)
1374  dd->winSetupGestures();
1375 #endif // Q_WS_WIN
1376 }
1377 
1379 {
1380  Q_Q(const QAbstractScrollArea);
1381  QPoint offset;
1382  if (vbar->isVisible())
1383  offset.setY(vbar->value());
1384  if (hbar->isVisible()) {
1385  if (q->isRightToLeft())
1386  offset.setX(hbar->maximum() - hbar->value());
1387  else
1388  offset.setX(hbar->value());
1389  }
1390  return offset;
1391 }
1392 
1398 {
1399  Q_D(const QAbstractScrollArea);
1400  int hsbExt = d->hbar->sizeHint().height();
1401  int vsbExt = d->vbar->sizeHint().width();
1402  int extra = 2 * d->frameWidth;
1403  QStyleOption opt;
1404  opt.initFrom(this);
1405  if ((d->frameStyle != QFrame::NoFrame)
1407  extra += style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, this);
1408  }
1409  return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra,
1410  d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra);
1411 }
1412 
1417 {
1418  return QSize(256, 192);
1419 #if 0
1420  Q_D(const QAbstractScrollArea);
1421  int h = qMax(10, fontMetrics().height());
1422  int f = 2 * d->frameWidth;
1423  return QSize((6 * h) + f, (4 * h) + f);
1424 #endif
1425 }
1426 
1436 {
1437  Q_UNUSED(viewport);
1438 }
1439 
1441 
1442 #include "moc_qabstractscrollarea.cpp"
1443 #include "moc_qabstractscrollarea_p.cpp"
1444 
1445 #endif // QT_NO_SCROLLAREA
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
bool hasTracking() const
void setViewportMargins(int left, int top, int right, int bottom)
Sets the margins around the scrolling area to left, top, right and bottom.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qframe.cpp:527
The QPanGesture class describes a panning gesture made by the user.
Definition: qgesture.h:107
The QKeyEvent class describes a key event.
Definition: qevent.h:224
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
int y() const
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setSpacing(int)
Definition: qlayout.cpp:469
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
QSize size() const
QPointer< QWidget > widget
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
bool acceptDrops() const
void dragMoveEvent(QDragMoveEvent *)
This event handler can be reimplemented in a subclass to receive drag move events (passed in event)...
int minimum() const
int sliderPosition() 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
void setLayout(QLayout *)
Sets the layout manager for this widget to layout.
Definition: qwidget.cpp:10104
QLayout * layout
Definition: qwidget_p.h:704
void mouseReleaseEvent(QMouseEvent *)
This event handler can be reimplemented in a subclass to receive mouse release events for the viewpor...
bool isVisible() const
Definition: qwidget.h:1005
bool isVisibleTo(QWidget *) const
Returns true if this widget would become visible if ancestor is shown; otherwise returns false...
Definition: qwidget.cpp:8371
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_WS_WIN
Defined on Windows.
Definition: qglobal.h:921
#define SLOT(a)
Definition: qobjectdefs.h:226
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void dragEnterEvent(QDragEnterEvent *)
This event handler can be reimplemented in a subclass to receive drag enter events (passed in event)...
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.
void init(const QWidget *w)
Use initFrom(widget) instead.
#define Q_ARG(type, data)
Definition: qobjectdefs.h:246
Qt::ScrollBarPolicy horizontalScrollBarPolicy() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
QWidget * cornerWidget() const
Returns the widget in the corner between the two scroll bars.
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void setInvertedAppearance(bool)
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
Definition: qevent.h:530
WindowType
Definition: qnamespace.h:270
void setupViewport(QWidget *viewport)
This slot is called by QAbstractScrollArea after setViewport(viewport) has been called.
QPointF delta
the offset from the previous input position to the current input
Definition: qgesture.h:114
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setRange(int min, int max)
Sets the slider&#39;s minimum to min and its maximum to max.
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QStyle * style() const
Definition: qwidget.cpp:2742
#define Q_Q(Class)
Definition: qglobal.h:2483
int top() const
Returns the top margin.
Definition: qmargins.h:99
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void wheelEvent(QWheelEvent *)
This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widg...
QWidget * viewport() const
Returns the viewport widget.
void setHorizontalScrollBar(QScrollBar *scrollbar)
Replaces the existing horizontal scroll bar with scrollBar, and sets all the former scroll bar&#39;s slid...
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive resize events (passed in event)...
#define SIGNAL(a)
Definition: qobjectdefs.h:227
bool isSliderDown() const
#define QT_RETHROW
Definition: qglobal.h:1539
void setInvertedControls(bool)
The QScrollBar widget provides a vertical or horizontal scroll bar.
Definition: qscrollbar.h:59
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int value() const
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
qreal & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:302
The QGestureEvent class provides the description of triggered gestures.
Definition: qevent.h:841
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
void contextMenuEvent(QContextMenuEvent *)
This event handler can be reimplemented in a subclass to receive context menu events for the viewport...
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events (passed in event)...
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
Inserts widget at position index, with stretch factor stretch and alignment alignment.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
void mousePressEvent(QMouseEvent *)
This event handler can be reimplemented in a subclass to receive mouse press events for the viewport(...
int manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
Definition: qpoint.cpp:489
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
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
const char * styleHint(const QFontDef &request)
Q_CORE_EXPORT void qWarning(const char *,...)
Qt::Orientation orientation() const
int scrollBarLayoutIndex() const
Returns the layout index for the scroll bar.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
bool invertedControls() const
bool invertedAppearance() const
void show()
Shows the widget and its child widgets.
#define QT_CATCH(A)
Definition: qglobal.h:1537
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.
void setSliderDown(bool)
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
void hide()
Hides the widget.
Definition: qwidget.h:501
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual bool viewportEvent(QEvent *)
The main event handler for the scrolling area (the viewport() widget).
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
QWidgetList widgets(LogicalPosition position)
Retuns a list of scroll bar widgets for the given position.
Qt::ScrollBarPolicy verticalScrollBarPolicy() const
QSize maximumViewportSize() const
Returns the size of the viewport as if the scroll bars had no valid scrolling range.
void setHorizontalPolicy(Policy d)
Definition: qsizepolicy.h:122
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int x() const
Qt::LayoutDirection layoutDirection() const
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
virtual int count() const =0
Must be implemented in subclasses to return the number of items in the layout.
bool hasMouseTracking() const
Definition: qwidget.h:993
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition: qlayout.cpp:319
void addWidget(QWidget *widget, LogicalPosition position)
Adds a widget to the scroll bar container.
void setCornerWidget(QWidget *widget)
Sets the widget in the corner between the two scroll bars to be widget.
ScrollBarPolicy
Definition: qnamespace.h:1420
QSizePolicy sizePolicy
the default layout behavior of the widget
Definition: qwidget.h:171
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool event(QEvent *e)
Reimplemented Function
Definition: qframe.cpp:587
void setSliderPosition(int)
QScrollBar * horizontalScrollBar() const
Returns the horizontal scroll bar.
void dropEvent(QDropEvent *)
This event handler can be reimplemented in a subclass to receive drop events (passed in event)...
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
QSize minimumSizeHint() const
Reimplemented Function
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
void dragLeaveEvent(QDragLeaveEvent *)
This event handler can be reimplemented in a subclass to receive drag leave events (passed in event)...
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
Definition: qpoint.h:277
static Qt::Orientation scrollBarOrientation(const QAInterface &scrollBar)
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
virtual void scrollContentsBy(int dx, int dy)
This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewpor...
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QObject * parent
Definition: qobject.h:92
QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent)
void addScrollBarWidget(QWidget *widget, Qt::Alignment alignment)
Adds widget as a scroll bar widget in the location specified by alignment.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
bool event(QEvent *)
Reimplemented Function
int left() const
Returns the left margin.
Definition: qmargins.h:96
void setVerticalPolicy(Policy d)
Definition: qsizepolicy.h:123
QGesture * gesture(Qt::GestureType type) const
Returns a gesture object by type.
Definition: qevent.cpp:4881
int singleStep() const
void setOrientation(Qt::Orientation)
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void keyPressEvent(QKeyEvent *)
This function is called with key event e when key presses occur.
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
void setViewport(QWidget *widget)
Sets the viewport to be the given widget.
void setSingleFingerPanEnabled(bool on=true)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void setTracking(bool enable)
void replaceScrollBar(QScrollBar *scrollBar, Qt::Orientation orientation)
The QMargins class defines the four margins of a rectangle.
Definition: qmargins.h:53
~QAbstractScrollArea()
Destroys the viewport.
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
int maximum() const
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
QWidgetList scrollBarWidgets(Qt::Alignment alignment)
Returns a list of the currently set scroll bar widgets.
bool qt_mac_checkForNativeSizeGrip(const QWidget *widget)
void setMargin(int)
Definition: qlayout.cpp:464
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
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
int bottom() const
Returns the bottom margin.
Definition: qmargins.h:105
int pageStep() const
QSize sizeHint() const
Reimplemented Function
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define QT_TRY
Definition: qglobal.h:1536
void setVerticalScrollBar(QScrollBar *scrollbar)
Replaces the existing vertical scroll bar with scrollBar, and sets all the former scroll bar&#39;s slider...
int right() const
Returns the right margin.
Definition: qmargins.h:102
virtual QPoint contentsOffset() const
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void mouseDoubleClickEvent(QMouseEvent *)
This event handler can be reimplemented in a subclass to receive mouse double click events for the vi...
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition: qlayout.cpp:1516
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void mouseMoveEvent(QMouseEvent *)
This event handler can be reimplemented in a subclass to receive mouse move events for the viewport()...
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...