Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qabstractscrollarea.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#if QT_CONFIG(scrollarea)
7
8#include "qscrollbar.h"
9#include "qapplication.h"
10#include "qstyle.h"
11#include "qstyleoption.h"
12#include "qevent.h"
13#include "qdebug.h"
14#include "qboxlayout.h"
15#include "qpainter.h"
16#include "qmargins.h"
17#if QT_CONFIG(itemviews)
18#include "qheaderview.h"
19#endif
20
21#include <QDebug>
22
24#include "qscrollbar_p.h"
25#include <qwidget.h>
26
27#include <private/qapplication_p.h>
28
29#ifdef Q_OS_WIN
30# include <qt_windows.h>
31#endif
32
34
35using namespace Qt::StringLiterals;
36
129QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
130 :hbar(nullptr), vbar(nullptr), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
131 shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored),
132 viewport(nullptr), cornerWidget(nullptr), left(0), top(0), right(0), bottom(0),
133 xoffset(0), yoffset(0), viewportFilter(nullptr)
134{
135}
136
137QAbstractScrollAreaPrivate::~QAbstractScrollAreaPrivate()
138{
139}
140
141QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent)
142 :QWidget(parent), scrollBar(new QScrollBar(orientation, this)),
143 layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)),
144 orientation(orientation)
145{
148 layout->setSpacing(0);
151}
152
156void QAbstractScrollAreaScrollBarContainer::addWidget(QWidget *widget, LogicalPosition position)
157{
159 if (orientation == Qt::Vertical)
161 else
164 widget->setParent(this);
165
166 const int insertIndex = (position & LogicalLeft) ? 0 : scrollBarLayoutIndex() + 1;
167 layout->insertWidget(insertIndex, widget);
168}
169
174QWidgetList QAbstractScrollAreaScrollBarContainer::widgets(LogicalPosition position)
175{
177 const int scrollBarIndex = scrollBarLayoutIndex();
178 if (position == LogicalLeft) {
179 list.reserve(scrollBarIndex);
180 for (int i = 0; i < scrollBarIndex; ++i)
182 } else if (position == LogicalRight) {
183 const int layoutItemCount = layout->count();
184 list.reserve(layoutItemCount - (scrollBarIndex + 1));
185 for (int i = scrollBarIndex + 1; i < layoutItemCount; ++i)
187 }
188 return list;
189}
190
197int QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex() const
198{
199 const int layoutItemCount = layout->count();
200 for (int i = 0; i < layoutItemCount; ++i) {
201 if (qobject_cast<QScrollBar *>(layout->itemAt(i)->widget()))
202 return i;
203 }
204 return -1;
205}
206
209void QAbstractScrollAreaPrivate::replaceScrollBar(QScrollBar *scrollBar,
210 Qt::Orientation orientation)
211{
212 Q_Q(QAbstractScrollArea);
213
214 QAbstractScrollAreaScrollBarContainer *container = scrollBarContainers[orientation];
215 bool horizontal = (orientation == Qt::Horizontal);
216 QScrollBar *oldBar = horizontal ? hbar : vbar;
217 if (horizontal)
218 hbar = scrollBar;
219 else
220 vbar = scrollBar;
221 scrollBar->setParent(container);
222 container->scrollBar = scrollBar;
223 container->layout->removeWidget(oldBar);
224 container->layout->insertWidget(0, scrollBar);
225 scrollBar->setVisible(oldBar->isVisibleTo(container));
226 scrollBar->setInvertedAppearance(oldBar->invertedAppearance());
227 scrollBar->setInvertedControls(oldBar->invertedControls());
228 scrollBar->setRange(oldBar->minimum(), oldBar->maximum());
229 scrollBar->setOrientation(oldBar->orientation());
230 scrollBar->setPageStep(oldBar->pageStep());
231 scrollBar->setSingleStep(oldBar->singleStep());
232 scrollBar->d_func()->viewMayChangeSingleStep = oldBar->d_func()->viewMayChangeSingleStep;
233 scrollBar->setSliderDown(oldBar->isSliderDown());
234 scrollBar->setSliderPosition(oldBar->sliderPosition());
235 scrollBar->setTracking(oldBar->hasTracking());
236 scrollBar->setValue(oldBar->value());
238 oldBar->removeEventFilter(q);
239 delete oldBar;
240
241 QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
242 q, horizontal ? SLOT(_q_hslide(int)) : SLOT(_q_vslide(int)));
243 QObject::connect(scrollBar, SIGNAL(rangeChanged(int,int)),
244 q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
245}
246
247void QAbstractScrollAreaPrivate::init()
248{
249 Q_Q(QAbstractScrollArea);
250 viewport = new QWidget(q);
251 viewport->setObjectName("qt_scrollarea_viewport"_L1);
252 viewport->setBackgroundRole(QPalette::Base);
253 viewport->setAutoFillBackground(true);
254 scrollBarContainers[Qt::Horizontal] = new QAbstractScrollAreaScrollBarContainer(Qt::Horizontal, q);
255 scrollBarContainers[Qt::Horizontal]->setObjectName("qt_scrollarea_hcontainer"_L1);
256 hbar = scrollBarContainers[Qt::Horizontal]->scrollBar;
257 hbar->setRange(0,0);
258 scrollBarContainers[Qt::Horizontal]->setVisible(false);
259 hbar->installEventFilter(q);
260 QObject::connect(hbar, SIGNAL(valueChanged(int)), q, SLOT(_q_hslide(int)));
261 QObject::connect(hbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
262 scrollBarContainers[Qt::Vertical] = new QAbstractScrollAreaScrollBarContainer(Qt::Vertical, q);
263 scrollBarContainers[Qt::Vertical]->setObjectName("qt_scrollarea_vcontainer"_L1);
264 vbar = scrollBarContainers[Qt::Vertical]->scrollBar;
265 vbar->setRange(0,0);
266 scrollBarContainers[Qt::Vertical]->setVisible(false);
267 vbar->installEventFilter(q);
268 QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));
269 QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
270 viewportFilter.reset(new QAbstractScrollAreaFilter(this));
271 viewport->installEventFilter(viewportFilter.data());
272 viewport->setFocusProxy(q);
273 q->setFocusPolicy(Qt::StrongFocus);
274 q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
276 layoutChildren();
277#ifndef Q_OS_MACOS
278# ifndef QT_NO_GESTURES
279 viewport->grabGesture(Qt::PanGesture);
280# endif
281#endif
282}
283
284void QAbstractScrollAreaPrivate::layoutChildren()
285{
286 bool needH = false;
287 bool needV = false;
288 layoutChildren_helper(&needH, &needV);
289 // Call a second time if one scrollbar was needed and not the other to
290 // check if it needs to readjust accordingly
291 if (needH != needV)
292 layoutChildren_helper(&needH, &needV);
293}
294
295void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrollbar, bool *needVerticalScrollbar)
296{
297 Q_Q(QAbstractScrollArea);
298 QStyleOptionSlider barOpt;
299
300 hbar->initStyleOption(&barOpt);
301 bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, &barOpt, hbar);
302 bool needh = *needHorizontalScrollbar || ((hbarpolicy != Qt::ScrollBarAlwaysOff) && ((hbarpolicy == Qt::ScrollBarAlwaysOn && !htransient)
303 || ((hbarpolicy == Qt::ScrollBarAsNeeded || htransient)
304 && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty())));
305 const int hscrollOverlap = hbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &barOpt, hbar);
306
307 vbar->initStyleOption(&barOpt);
308 bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, &barOpt, vbar);
309 bool needv = *needVerticalScrollbar || ((vbarpolicy != Qt::ScrollBarAlwaysOff) && ((vbarpolicy == Qt::ScrollBarAlwaysOn && !vtransient)
310 || ((vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)
311 && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty())));
312 const int vscrollOverlap = vbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &barOpt, vbar);
313
314 QStyleOption opt(0);
315 opt.initFrom(q);
316
317 const int hsbExt = hbar->sizeHint().height();
318 const int vsbExt = vbar->sizeHint().width();
319 const QPoint extPoint(vsbExt, hsbExt);
320 const QSize extSize(vsbExt, hsbExt);
321
322 const QRect widgetRect = q->rect();
323
324 const bool hasCornerWidget = (cornerWidget != nullptr);
325
326 QPoint cornerOffset((needv && vscrollOverlap == 0) ? vsbExt : 0, (needh && hscrollOverlap == 0) ? hsbExt : 0);
327 QRect controlsRect;
328 QRect viewportRect;
329
330 // In FrameOnlyAroundContents mode the frame is drawn between the controls and
331 // the viewport, else the frame rect is equal to the widget rect.
332 if ((frameStyle != QFrame::NoFrame) &&
333 q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
334 controlsRect = widgetRect;
335 const int spacing = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);
336 const QPoint cornerExtra(needv ? spacing + vscrollOverlap : 0, needh ? spacing + hscrollOverlap : 0);
337 QRect frameRect = widgetRect;
338 frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y());
339 q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, frameRect));
340 // The frame rect needs to be in logical coords, however we need to flip
341 // the contentsRect back before passing it on to the viewportRect
342 // since the viewportRect has its logical coords calculated later.
343 viewportRect = QStyle::visualRect(opt.direction, opt.rect, q->contentsRect());
344 } else {
345 q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, widgetRect));
346 controlsRect = q->contentsRect();
347 viewportRect = QRect(controlsRect.topLeft(), controlsRect.bottomRight() - cornerOffset);
348 }
349
350 cornerOffset = QPoint(needv ? vsbExt : 0, needh ? hsbExt : 0);
351
352 // If we have a corner widget and are only showing one scroll bar, we need to move it
353 // to make room for the corner widget.
354 if (hasCornerWidget && ((needv && vscrollOverlap == 0) || (needh && hscrollOverlap == 0)))
355 cornerOffset = extPoint;
356
357 // The corner point is where the scroll bar rects, the corner widget rect and the
358 // viewport rect meets.
359 const QPoint cornerPoint(controlsRect.bottomRight() + QPoint(1, 1) - cornerOffset);
360
361 // Some styles paints the corner if both scorllbars are showing and there is
362 // no corner widget.
363 if (needv && needh && !hasCornerWidget && hscrollOverlap == 0 && vscrollOverlap == 0)
364 cornerPaintingRect = QStyle::visualRect(opt.direction, opt.rect, QRect(cornerPoint, extSize));
365 else
366 cornerPaintingRect = QRect();
367
368 // move the scrollbars away from top/left headers
369 int vHeaderRight = 0;
370 int hHeaderBottom = 0;
371#if QT_CONFIG(itemviews)
372 if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) {
373 const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>();
374 if (headers.size() <= 2) {
375 for (const QHeaderView *header : headers) {
376 const QRect geo = header->geometry();
377 if (header->orientation() == Qt::Vertical && header->isVisible() && QStyle::visualRect(opt.direction, opt.rect, geo).left() <= opt.rect.width() / 2)
378 vHeaderRight = QStyle::visualRect(opt.direction, opt.rect, geo).right();
379 else if (header->orientation() == Qt::Horizontal && header->isVisible() && geo.top() <= q->frameWidth())
380 hHeaderBottom = geo.bottom();
381 }
382 }
383 }
384#endif // QT_CONFIG(itemviews)
385 if (needh) {
386 QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom()));
387
388 if (!hasCornerWidget && htransient)
389 horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0);
390 scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect));
391 scrollBarContainers[Qt::Horizontal]->raise();
392 }
393
394 if (needv) {
395 QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top() + hHeaderBottom), QPoint(controlsRect.right(), cornerPoint.y() - 1));
396 if (!hasCornerWidget && vtransient)
397 verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y());
398 scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect));
399 scrollBarContainers[Qt::Vertical]->raise();
400 }
401
402 if (cornerWidget) {
403 const QRect cornerWidgetRect(cornerPoint, controlsRect.bottomRight());
404 cornerWidget->setGeometry(QStyle::visualRect(opt.direction, opt.rect, cornerWidgetRect));
405 }
406
407 scrollBarContainers[Qt::Horizontal]->setVisible(needh);
408 scrollBarContainers[Qt::Vertical]->setVisible(needv);
409
410 if (q->isRightToLeft())
411 viewportRect.adjust(right, top, -left, -bottom);
412 else
413 viewportRect.adjust(left, top, -right, -bottom);
414 viewportRect = QStyle::visualRect(opt.direction, opt.rect, viewportRect);
415 viewportRect.translate(-overshoot);
416 viewport->setGeometry(viewportRect); // resize the viewport last
417
418 *needHorizontalScrollbar = needh;
419 *needVerticalScrollbar = needv;
420}
421
440QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent)
441 :QFrame(dd, parent)
442{
443 Q_D(QAbstractScrollArea);
444 QT_TRY {
445 d->init();
446 } QT_CATCH(...) {
447 d->viewportFilter.reset();
449 }
450}
451
457QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)
458 :QFrame(*new QAbstractScrollAreaPrivate, parent)
459{
460 Q_D(QAbstractScrollArea);
461 QT_TRY {
462 d->init();
463 } QT_CATCH(...) {
464 d->viewportFilter.reset();
466 }
467}
468
469
473QAbstractScrollArea::~QAbstractScrollArea()
474{
475 Q_D(QAbstractScrollArea);
476 // reset it here, otherwise we'll have a dangling pointer in ~QWidget
477 d->viewportFilter.reset();
478}
479
480
491void QAbstractScrollArea::setViewport(QWidget *widget)
492{
493 Q_D(QAbstractScrollArea);
494 if (widget != d->viewport) {
495 QWidget *oldViewport = d->viewport;
496 if (!widget)
497 widget = new QWidget;
498 d->viewport = widget;
499 d->viewport->setParent(this);
500 d->viewport->setFocusProxy(this);
501 d->viewport->installEventFilter(d->viewportFilter.data());
502#ifndef QT_NO_GESTURES
503 d->viewport->grabGesture(Qt::PanGesture);
504#endif
505 d->layoutChildren();
506#ifndef QT_NO_OPENGL
507 QWidgetPrivate::get(d->viewport)->initializeViewportFramebuffer();
508#endif
509 if (isVisible())
510 d->viewport->show();
511 setupViewport(widget);
512 delete oldViewport;
513 }
514}
515
524QWidget *QAbstractScrollArea::viewport() const
525{
526 Q_D(const QAbstractScrollArea);
527 return d->viewport;
528}
529
530
535QSize QAbstractScrollArea::maximumViewportSize() const
536{
537 Q_D(const QAbstractScrollArea);
538 int f = 2 * d->frameWidth;
539 QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom);
540 // Count the sizeHint of the bar only if it is displayed.
541 if (d->vbarpolicy == Qt::ScrollBarAlwaysOn)
542 max.rwidth() -= d->vbar->sizeHint().width();
543 if (d->hbarpolicy == Qt::ScrollBarAlwaysOn)
544 max.rheight() -= d->hbar->sizeHint().height();
545 return max;
546}
547
557Qt::ScrollBarPolicy QAbstractScrollArea::verticalScrollBarPolicy() const
558{
559 Q_D(const QAbstractScrollArea);
560 return d->vbarpolicy;
561}
562
563void QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
564{
565 Q_D(QAbstractScrollArea);
566 const Qt::ScrollBarPolicy oldPolicy = d->vbarpolicy;
567 d->vbarpolicy = policy;
568 if (isVisible())
569 d->layoutChildren();
570 if (oldPolicy != d->vbarpolicy)
571 d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);
572}
573
574
580QScrollBar *QAbstractScrollArea::verticalScrollBar() const
581{
582 Q_D(const QAbstractScrollArea);
583 return d->vbar;
584}
585
598void QAbstractScrollArea::setVerticalScrollBar(QScrollBar *scrollBar)
599{
600 Q_D(QAbstractScrollArea);
601 if (Q_UNLIKELY(!scrollBar)) {
602 qWarning("QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar");
603 return;
604 }
605
606 d->replaceScrollBar(scrollBar, Qt::Vertical);
607}
608
618Qt::ScrollBarPolicy QAbstractScrollArea::horizontalScrollBarPolicy() const
619{
620 Q_D(const QAbstractScrollArea);
621 return d->hbarpolicy;
622}
623
624void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
625{
626 Q_D(QAbstractScrollArea);
627 const Qt::ScrollBarPolicy oldPolicy = d->hbarpolicy;
628 d->hbarpolicy = policy;
629 if (isVisible())
630 d->layoutChildren();
631 if (oldPolicy != d->hbarpolicy)
632 d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);
633}
634
640QScrollBar *QAbstractScrollArea::horizontalScrollBar() const
641{
642 Q_D(const QAbstractScrollArea);
643 return d->hbar;
644}
645
659void QAbstractScrollArea::setHorizontalScrollBar(QScrollBar *scrollBar)
660{
661 Q_D(QAbstractScrollArea);
662 if (Q_UNLIKELY(!scrollBar)) {
663 qWarning("QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar");
664 return;
665 }
666
667 d->replaceScrollBar(scrollBar, Qt::Horizontal);
668}
669
677QWidget *QAbstractScrollArea::cornerWidget() const
678{
679 Q_D(const QAbstractScrollArea);
680 return d->cornerWidget;
681}
682
709void QAbstractScrollArea::setCornerWidget(QWidget *widget)
710{
711 Q_D(QAbstractScrollArea);
712 QWidget* oldWidget = d->cornerWidget;
713 if (oldWidget != widget) {
714 if (oldWidget)
715 oldWidget->hide();
716 d->cornerWidget = widget;
717
718 if (widget && widget->parentWidget() != this)
719 widget->setParent(this);
720
721 d->layoutChildren();
722 if (widget)
723 widget->show();
724 } else {
725 d->cornerWidget = widget;
726 d->layoutChildren();
727 }
728}
729
762void QAbstractScrollArea::addScrollBarWidget(QWidget *widget, Qt::Alignment alignment)
763{
764 Q_D(QAbstractScrollArea);
765
766 if (widget == nullptr)
767 return;
768
769 const Qt::Orientation scrollBarOrientation
771 const QAbstractScrollAreaScrollBarContainer::LogicalPosition position
773 ? QAbstractScrollAreaScrollBarContainer::LogicalRight : QAbstractScrollAreaScrollBarContainer::LogicalLeft;
774 d->scrollBarContainers[scrollBarOrientation]->addWidget(widget, position);
775 d->layoutChildren();
776 if (isHidden() == false)
777 widget->show();
778}
779
787QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment)
788{
789 Q_D(QAbstractScrollArea);
790
792
794 list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
796 list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
798 list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
800 list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
801
802 return list;
803}
804
819void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom)
820{
821 Q_D(QAbstractScrollArea);
822 d->left = left;
823 d->top = top;
824 d->right = right;
825 d->bottom = bottom;
826 d->layoutChildren();
827}
828
839void QAbstractScrollArea::setViewportMargins(const QMargins &margins)
840{
841 setViewportMargins(margins.left(), margins.top(),
842 margins.right(), margins.bottom());
843}
844
852QMargins QAbstractScrollArea::viewportMargins() const
853{
854 Q_D(const QAbstractScrollArea);
855 return QMargins(d->left, d->top, d->right, d->bottom);
856}
857
859bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e)
860{
861 Q_D(QAbstractScrollArea);
862 if ((o == d->hbar || o == d->vbar) && (e->type() == QEvent::HoverEnter || e->type() == QEvent::HoverLeave)) {
863 if (d->hbarpolicy == Qt::ScrollBarAsNeeded && d->vbarpolicy == Qt::ScrollBarAsNeeded) {
864 QScrollBar *sbar = static_cast<QScrollBar*>(o);
865 QScrollBar *sibling = sbar == d->hbar ? d->vbar : d->hbar;
866 if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, sbar) &&
867 sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, sibling))
868 d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave);
869 }
870 }
871 return QFrame::eventFilter(o, e);
872}
873
886bool QAbstractScrollArea::event(QEvent *e)
887{
888 Q_D(QAbstractScrollArea);
889 switch (e->type()) {
891 // There was a chance that with accessibility client we get an
892 // event before the viewport was created.
893 // Also, in some cases we might get here from QWidget::event() virtual function which is (indirectly) called
894 // from the viewport constructor at the time when the d->viewport is not yet initialized even without any
895 // accessibility client. See qabstractscrollarea autotest for a test case.
896 if (d->viewport)
897 d->viewport->setAcceptDrops(acceptDrops());
898 break;
900 d->viewport->setMouseTracking(hasMouseTracking());
901 break;
902 case QEvent::Resize:
903 if (!d->inResize) {
904 d->inResize = true;
905 d->layoutChildren();
906 d->inResize = false;
907 }
908 break;
909 case QEvent::Show:
910 if (!d->shownOnce && d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContentsOnFirstShow) {
911 d->sizeHint = QSize();
912 updateGeometry();
913 }
914 d->shownOnce = true;
915 return QFrame::event(e);
916 case QEvent::Paint: {
918 option.initFrom(this);
919 if (d->cornerPaintingRect.isValid()) {
920 option.rect = d->cornerPaintingRect;
921 QPainter p(this);
922 style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this);
923 }
924 }
926 break;
927#ifndef QT_NO_CONTEXTMENU
929 if (static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard)
930 return QFrame::event(e);
931 e->ignore();
932 break;
933#endif // QT_NO_CONTEXTMENU
938 case QEvent::Wheel:
939#if QT_CONFIG(draganddrop)
940 case QEvent::Drop:
942 case QEvent::DragMove:
944#endif
945 // ignore touch events in case they have been propagated from the viewport
948 case QEvent::TouchEnd:
949 return false;
950#ifndef QT_NO_GESTURES
951 case QEvent::Gesture:
952 {
953 QGestureEvent *ge = static_cast<QGestureEvent *>(e);
954 QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture));
955 if (g) {
956 QScrollBar *hBar = horizontalScrollBar();
957 QScrollBar *vBar = verticalScrollBar();
958 QPointF delta = g->delta();
959 if (!delta.isNull()) {
961 delta.rx() *= -1;
962 int newX = hBar->value() - delta.x();
963 int newY = vBar->value() - delta.y();
964 hBar->setValue(newX);
965 vBar->setValue(newY);
966 }
967 return true;
968 }
969 return false;
970 }
971#endif // QT_NO_GESTURES
973 {
974 QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
975 if (d->canStartScrollingAt(se->startPos().toPoint())) {
976 QScrollBar *hBar = horizontalScrollBar();
977 QScrollBar *vBar = verticalScrollBar();
978
979 se->setViewportSize(QSizeF(viewport()->size()));
980 se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));
981 se->setContentPos(QPointF(hBar->value(), vBar->value()));
982 se->accept();
983 return true;
984 }
985 return false;
986 }
987 case QEvent::Scroll:
988 {
989 QScrollEvent *se = static_cast<QScrollEvent *>(e);
990
991 QScrollBar *hBar = horizontalScrollBar();
992 QScrollBar *vBar = verticalScrollBar();
993 hBar->setValue(se->contentPos().x());
994 vBar->setValue(se->contentPos().y());
995
996 QPoint delta = d->overshoot - se->overshootDistance().toPoint();
997 if (!delta.isNull())
998 viewport()->move(viewport()->pos() + delta);
999
1000 d->overshoot = se->overshootDistance().toPoint();
1001
1002 return true;
1003 }
1008 d->layoutChildren();
1009 Q_FALLTHROUGH();
1010 default:
1011 return QFrame::event(e);
1012 }
1013 return true;
1014}
1015
1036bool QAbstractScrollArea::viewportEvent(QEvent *e)
1037{
1038 switch (e->type()) {
1039 case QEvent::Resize:
1040 case QEvent::Paint:
1044 case QEvent::TouchBegin:
1046 case QEvent::TouchEnd:
1047 case QEvent::MouseMove:
1049#if QT_CONFIG(wheelevent)
1050 case QEvent::Wheel:
1051#endif
1052#if QT_CONFIG(draganddrop)
1053 case QEvent::Drop:
1054 case QEvent::DragEnter:
1055 case QEvent::DragMove:
1056 case QEvent::DragLeave:
1057#endif
1058#ifndef QT_NO_OPENGL
1059 // QOpenGLWidget needs special support because it has to know
1060 // its size has changed, so that it can resize its fbo.
1061 if (e->type() == QEvent::Resize)
1062 QWidgetPrivate::get(viewport())->resizeViewportFramebuffer();
1063#endif
1064 return QFrame::event(e);
1066#ifndef QT_NO_GESTURES
1067 case QEvent::Gesture:
1069 return event(e);
1070#endif
1072 case QEvent::Scroll:
1073 return event(e);
1074 default:
1075 break;
1076 }
1077 return false; // let the viewport widget handle the event
1078}
1079
1093void QAbstractScrollArea::resizeEvent(QResizeEvent *)
1094{
1095}
1096
1107void QAbstractScrollArea::paintEvent(QPaintEvent*)
1108{
1109}
1110
1121void QAbstractScrollArea::mousePressEvent(QMouseEvent *e)
1122{
1124}
1125
1133void QAbstractScrollArea::mouseReleaseEvent(QMouseEvent *e)
1134{
1135 e->ignore();
1136}
1137
1145void QAbstractScrollArea::mouseDoubleClickEvent(QMouseEvent *e)
1146{
1147 e->ignore();
1148}
1149
1157void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e)
1158{
1159 e->ignore();
1160}
1161
1169#if QT_CONFIG(wheelevent)
1170void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
1171{
1172 Q_D(QAbstractScrollArea);
1173 if (qAbs(e->angleDelta().x()) > qAbs(e->angleDelta().y()))
1175 else
1177}
1178#endif
1179
1180#ifndef QT_NO_CONTEXTMENU
1188void QAbstractScrollArea::contextMenuEvent(QContextMenuEvent *e)
1189{
1190 e->ignore();
1191}
1192#endif // QT_NO_CONTEXTMENU
1193
1199void QAbstractScrollArea::keyPressEvent(QKeyEvent * e)
1200{
1201 Q_D(QAbstractScrollArea);
1202 if (false){
1203#ifndef QT_NO_SHORTCUT
1204 } else if (e == QKeySequence::MoveToPreviousPage) {
1205 d->vbar->triggerAction(QScrollBar::SliderPageStepSub);
1206 } else if (e == QKeySequence::MoveToNextPage) {
1207 d->vbar->triggerAction(QScrollBar::SliderPageStepAdd);
1208#endif
1209 } else {
1210#ifdef QT_KEYPAD_NAVIGATION
1211 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
1212 e->ignore();
1213 return;
1214 }
1215#endif
1216 switch (e->key()) {
1217 case Qt::Key_Up:
1218 d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);
1219 break;
1220 case Qt::Key_Down:
1221 d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);
1222 break;
1223 case Qt::Key_Left:
1224#ifdef QT_KEYPAD_NAVIGATION
1225 if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
1226 && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {
1227 //if we aren't using the hbar or we are already at the leftmost point ignore
1228 e->ignore();
1229 return;
1230 }
1231#endif
1232 d->hbar->triggerAction(
1233 layoutDirection() == Qt::LeftToRight
1234 ? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd);
1235 break;
1236 case Qt::Key_Right:
1237#ifdef QT_KEYPAD_NAVIGATION
1238 if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
1239 && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {
1240 //if we aren't using the hbar or we are already at the rightmost point ignore
1241 e->ignore();
1242 return;
1243 }
1244#endif
1245 d->hbar->triggerAction(
1246 layoutDirection() == Qt::LeftToRight
1247 ? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);
1248 break;
1249 default:
1250 e->ignore();
1251 return;
1252 }
1253 }
1254 e->accept();
1255}
1256
1257
1258#if QT_CONFIG(draganddrop)
1267void QAbstractScrollArea::dragEnterEvent(QDragEnterEvent *)
1268{
1269}
1270
1279void QAbstractScrollArea::dragMoveEvent(QDragMoveEvent *)
1280{
1281}
1282
1291void QAbstractScrollArea::dragLeaveEvent(QDragLeaveEvent *)
1292{
1293}
1294
1303void QAbstractScrollArea::dropEvent(QDropEvent *)
1304{
1305}
1306
1307
1308#endif
1309
1328void QAbstractScrollArea::scrollContentsBy(int, int)
1329{
1330 viewport()->update();
1331}
1332
1333bool QAbstractScrollAreaPrivate::canStartScrollingAt(const QPoint &startPos) const
1334{
1335 Q_Q(const QAbstractScrollArea);
1336
1337 // don't start scrolling on a QAbstractSlider
1338 if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos)))
1339 return false;
1340
1341 return true;
1342}
1343
1344void QAbstractScrollAreaPrivate::flashScrollBars()
1345{
1346 QStyleOptionSlider opt;
1347 hbar->initStyleOption(&opt);
1348
1349 bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, &opt, hbar);
1350 if ((hbarpolicy != Qt::ScrollBarAlwaysOff) && (hbarpolicy == Qt::ScrollBarAsNeeded || htransient))
1351 hbar->d_func()->flash();
1352 vbar->initStyleOption(&opt);
1353 bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, &opt, vbar);
1354 if ((vbarpolicy != Qt::ScrollBarAlwaysOff) && (vbarpolicy == Qt::ScrollBarAsNeeded || vtransient))
1355 vbar->d_func()->flash();
1356}
1357
1358void QAbstractScrollAreaPrivate::setScrollBarTransient(QScrollBar *scrollBar, bool transient)
1359{
1360 scrollBar->d_func()->setTransient(transient);
1361}
1362
1363void QAbstractScrollAreaPrivate::_q_hslide(int x)
1364{
1365 Q_Q(QAbstractScrollArea);
1366 int dx = xoffset - x;
1367 xoffset = x;
1368 q->scrollContentsBy(dx, 0);
1369 flashScrollBars();
1370}
1371
1372void QAbstractScrollAreaPrivate::_q_vslide(int y)
1373{
1374 Q_Q(QAbstractScrollArea);
1375 int dy = yoffset - y;
1376 yoffset = y;
1377 q->scrollContentsBy(0, dy);
1378 flashScrollBars();
1379}
1380
1381void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars()
1382{
1383 layoutChildren();
1384}
1385
1386QPoint QAbstractScrollAreaPrivate::contentsOffset() const
1387{
1388 Q_Q(const QAbstractScrollArea);
1389 QPoint offset;
1390 if (vbar->isVisible())
1391 offset.setY(vbar->value());
1392 if (hbar->isVisible()) {
1393 if (q->isRightToLeft())
1394 offset.setX(hbar->maximum() - hbar->value());
1395 else
1396 offset.setX(hbar->value());
1397 }
1398 return offset;
1399}
1400
1405QSize QAbstractScrollArea::minimumSizeHint() const
1406{
1407 Q_D(const QAbstractScrollArea);
1408 int hsbExt = d->hbar->sizeHint().height();
1409 int vsbExt = d->vbar->sizeHint().width();
1410 int extra = 2 * d->frameWidth;
1412 opt.initFrom(this);
1413 if ((d->frameStyle != QFrame::NoFrame)
1414 && style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, this)) {
1415 extra += style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, this);
1416 }
1417 return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra,
1418 d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra);
1419}
1420
1426QSize QAbstractScrollArea::sizeHint() const
1427{
1428 Q_D(const QAbstractScrollArea);
1429 if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
1430 return QSize(256, 192);
1431
1432 if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
1433 const int f = 2 * d->frameWidth;
1434 const QSize frame(f, f);
1435 const bool vbarHidden = !d->vbar->isVisibleTo(this) || d->vbarpolicy == Qt::ScrollBarAlwaysOff;
1436 const bool hbarHidden = !d->vbar->isVisibleTo(this) || d->hbarpolicy == Qt::ScrollBarAlwaysOff;
1437 const QSize scrollbars(vbarHidden ? 0 : d->vbar->sizeHint().width(),
1438 hbarHidden ? 0 : d->hbar->sizeHint().height());
1439 d->sizeHint = frame + scrollbars + viewportSizeHint();
1440 }
1441 return d->sizeHint;
1442}
1443
1450QSize QAbstractScrollArea::viewportSizeHint() const
1451{
1452 Q_D(const QAbstractScrollArea);
1453 if (d->viewport) {
1454 const QSize sh = d->viewport->sizeHint();
1455 if (sh.isValid()) {
1456 return sh;
1457 }
1458 }
1459 const int h = qMax(10, fontMetrics().height());
1460 return QSize(6 * h, 4 * h);
1461}
1462
1473QAbstractScrollArea::SizeAdjustPolicy QAbstractScrollArea::sizeAdjustPolicy() const
1474{
1475 Q_D(const QAbstractScrollArea);
1476 return d->sizeAdjustPolicy;
1477}
1478
1479void QAbstractScrollArea::setSizeAdjustPolicy(SizeAdjustPolicy policy)
1480{
1481 Q_D(QAbstractScrollArea);
1482 if (d->sizeAdjustPolicy == policy)
1483 return;
1484
1485 d->sizeAdjustPolicy = policy;
1486 d->sizeHint = QSize();
1487 updateGeometry();
1488}
1489
1498void QAbstractScrollArea::setupViewport(QWidget *viewport)
1499{
1501}
1502
1504
1505#include "moc_qabstractscrollarea.cpp"
1506#include "moc_qabstractscrollarea_p.cpp"
1507
1508#endif // QT_CONFIG(scrollarea)
void setInvertedControls(bool)
void setTracking(bool enable)
void setInvertedAppearance(bool)
void setOrientation(Qt::Orientation)
void setRange(int min, int max)
Sets the slider's minimum to min and its maximum to max.
void setSliderPosition(int)
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition qboxlayout.h:21
int count() const override
\reimp
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
QLayoutItem * itemAt(int) const override
\reimp
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Inserts widget at position index, with stretch factor stretch and alignment alignment.
void setSpacing(int spacing) override
Reimplements QLayout::setSpacing().
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
\inmodule QtCore
Definition qcoreevent.h:45
@ GestureOverride
Definition qcoreevent.h:254
@ AcceptDropsChange
Definition qcoreevent.h:185
@ LayoutDirectionChange
Definition qcoreevent.h:124
@ ApplicationLayoutDirectionChange
Definition qcoreevent.h:92
@ StyleChange
Definition qcoreevent.h:136
@ DragEnter
Definition qcoreevent.h:101
@ LayoutRequest
Definition qcoreevent.h:112
@ MouseMove
Definition qcoreevent.h:63
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ HoverLeave
Definition qcoreevent.h:176
@ HoverEnter
Definition qcoreevent.h:175
@ DragLeave
Definition qcoreevent.h:103
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ ScrollPrepare
Definition qcoreevent.h:256
@ ContextMenu
Definition qcoreevent.h:119
@ MouseButtonRelease
Definition qcoreevent.h:61
@ MouseTrackingChange
Definition qcoreevent.h:139
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition qcoreevent.h:311
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition qcoreevent.h:310
The QFrame class is the base class of widgets that can have a frame.
Definition qframe.h:17
@ Sunken
Definition qframe.h:51
bool event(QEvent *e) override
\reimp
Definition qframe.cpp:511
void paintEvent(QPaintEvent *) override
\reimp
Definition qframe.cpp:477
@ StyledPanel
Definition qframe.h:45
@ NoFrame
Definition qframe.h:39
The QGestureEvent class provides the description of triggered gestures.
Definition qgesture.h:244
static bool isRightToLeft()
Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false.
The QHeaderView class provides a header row or header column for item views.
Definition qheaderview.h:18
The QKeyEvent class describes a key event.
Definition qevent.h:424
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
void setSizeConstraint(SizeConstraint)
Definition qlayout.cpp:1241
@ SetMaximumSize
Definition qlayout.h:40
void setContentsMargins(int left, int top, int right, int bottom)
Definition qlayout.cpp:288
void reserve(qsizetype size)
Definition qlist.h:753
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
Definition qmargins.h:24
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:115
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:106
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:112
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:109
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
Definition qobject.cpp:2339
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
Definition qobject.cpp:1555
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
The QPanGesture class describes a panning gesture made by the user.\inmodule QtWidgets.
Definition qgesture.h:73
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
constexpr qreal & rx() noexcept
Returns a reference to the x coordinate of this point.
Definition qpoint.h:363
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition qpoint.h:404
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
Definition qpoint.h:338
\inmodule QtCore\reentrant
Definition qpoint.h:25
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
Definition qpoint.h:125
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition qrect.h:373
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
Definition qrect.h:245
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QScrollBar widget provides a vertical or horizontal scroll bar.
Definition qscrollbar.h:20
The QScrollEvent class is sent when scrolling.
Definition qevent.h:976
The QScrollPrepareEvent class is sent in preparation of scrolling.
Definition qevent.h:952
\inmodule QtCore
Definition qsize.h:208
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
constexpr void setHorizontalPolicy(Policy d) noexcept
Sets the horizontal component to the given policy.
Definition qsizepolicy.h:70
constexpr void setVerticalPolicy(Policy d) noexcept
Sets the vertical component to the given policy.
Definition qsizepolicy.h:71
\inmodule QtCore
Definition qsize.h:25
constexpr int & rheight() noexcept
Returns a reference to the height.
Definition qsize.h:157
constexpr int & rwidth() noexcept
Returns a reference to the width.
Definition qsize.h:154
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
Definition qsize.h:127
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
Qt::LayoutDirection direction
@ SH_ScrollView_FrameOnlyAroundContents
Definition qstyle.h:602
@ SH_ScrollBar_Transient
Definition qstyle.h:681
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...
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:2143
@ PM_ScrollView_ScrollBarOverlap
Definition qstyle.h:526
@ PM_ScrollView_ScrollBarSpacing
Definition qstyle.h:525
@ PE_PanelScrollAreaCorner
Definition qstyle.h:146
static QWidgetPrivate * get(QWidget *w)
Definition qwidget_p.h:212
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
void setSizePolicy(QSizePolicy)
virtual void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition qwidget.cpp:9483
QSizePolicy sizePolicy
the default layout behavior of the widget
Definition qwidget.h:119
void hide()
Hides the widget.
Definition qwidget.cpp:8135
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
virtual void setVisible(bool visible)
Definition qwidget.cpp:8255
QStyle * style() const
Definition qwidget.cpp:2600
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
#define this
Definition dialogs.cpp:9
QOpenGLWidget * widget
[1]
qreal spacing
uint alignment
QStyleOptionButton opt
fontMetrics
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ AlignRight
Definition qnamespace.h:146
@ AlignBottom
Definition qnamespace.h:154
@ AlignTop
Definition qnamespace.h:153
@ AlignLeft
Definition qnamespace.h:144
@ LeftToRight
@ StrongFocus
Definition qnamespace.h:110
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ Key_Right
Definition qnamespace.h:679
@ Key_Left
Definition qnamespace.h:677
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
ScrollBarPolicy
@ ScrollBarAlwaysOff
@ ScrollBarAlwaysOn
@ ScrollBarAsNeeded
@ QueuedConnection
@ PanGesture
#define Q_FALLTHROUGH()
#define Q_UNLIKELY(x)
static QString header(const QString &name)
#define QT_RETHROW
#define QT_CATCH(A)
#define QT_TRY
#define qWarning
Definition qlogging.h:166
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLfloat GLfloat f
GLint GLint GLint yoffset
GLint GLsizei width
GLint left
GLint GLint bottom
GLint GLint xoffset
GLenum GLuint GLintptr offset
GLboolean GLboolean g
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
GLuint GLenum option
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_UNUSED(x)
QList< int > list
[14]
QObject::connect nullptr
QVBoxLayout * layout
QScrollBar * scrollBar
view viewport() -> scroll(dx, dy, deviceRect)
edit isVisible()
QFrame frame
[0]
groupBox setLayout(vbox)
QSizePolicy policy