257#include <QtCore/qdatetime.h>
258#include <QtCore/qdebug.h>
259#include <QtCore/qmath.h>
260#include <QtCore/qscopedvaluerollback.h>
261#include <QtWidgets/qapplication.h>
262#include <QtGui/qevent.h>
263#include <QtWidgets/qlayout.h>
264#include <QtGui/qtransform.h>
265#include <QtGui/qpainter.h>
266#include <QtGui/qpainterpath.h>
267#include <QtWidgets/qscrollbar.h>
268#include <QtWidgets/qstyleoption.h>
270#include <private/qevent_p.h>
271#include <QtGui/private/qeventpoint_p.h>
281 else if (
d >= (
qreal) INT_MAX)
283 return d >= 0.0 ? int(
d + 0.5) : int(
d -
int(
d-1) + 0.5) + int(
d-1);
288 for (
int i = 0;
i < touchEvent->pointCount(); ++
i) {
289 auto &pt = touchEvent->
point(
i);
292 QMutableEventPoint::setScenePosition(pt,
d->mapToScene(pt.position()));
301 : renderHints(
QPainter::TextAntialiasing),
303 sceneInteractionAllowed(true), hasSceneRect(
false),
304 connectedToScene(
false),
305 useLastMouseEvent(
false),
306 identityMatrix(true),
308 accelerateScrolling(true),
309 keepLastCenterPoint(true),
311 handScrolling(
false),
312 mustAllocateStyleOptions(
false),
313 mustResizeBackgroundPixmap(true),
314 fullUpdatePending(true),
315 hasUpdateClip(
false),
316 mousePressButton(
Qt::NoButton),
317 leftIndent(0), topIndent(0),
323 rubberBanding(
false),
324 rubberBandSelectionMode(
Qt::IntersectsItemShape),
325 rubberBandSelectionOperation(
Qt::ReplaceSelection),
327 handScrollMotions(0),
329 hasStoredOriginalCursor(
false),
332 updateSceneSlotReimplementedChecked(
false)
348 const QSize maxSize =
q->maximumViewportSize();
354 if (frameOnlyAround) {
358 width -= frameWidth * 2;
364 + (frameOnlyAround ? frameWidth * 2 : 0);
371 if (viewRect.height() >
height - scrollBarExtent)
372 useVerticalScrollBar =
true;
375 if (viewRect.width() >
width - scrollBarExtent)
376 useHorizontalScrollBar =
true;
378 if (useHorizontalScrollBar)
379 height -= scrollBarExtent;
380 if (useVerticalScrollBar)
381 width -= scrollBarExtent;
406 leftIndent = maxSize.
width() / 2 - (viewRect.left() + viewRect.right()) / 2;
410 hbar->setRange(0, 0);
415 hbar->setPageStep(
width);
416 hbar->setSingleStep(
width / 20);
418 if (oldLeftIndent != 0)
419 hbar->setValue(-oldLeftIndent);
436 topIndent = maxSize.
height() / 2 - (viewRect.top() + viewRect.bottom()) / 2;
440 vbar->setRange(0, 0);
445 vbar->setPageStep(
height);
446 vbar->setSingleStep(
height / 20);
448 if (oldTopIndent != 0)
449 vbar->setValue(-oldTopIndent);
483 if (
q->underMouse()) {
569 if (
q->isRightToLeft()) {
601 return QAbstractScrollAreaPrivate::canStartScrollingAt(startPos);
628#if QT_CONFIG(rubberband)
629 updateRubberBand(
event);
659 if (
event->spontaneous())
678 if (
scene->d_func()->allItemsIgnoreHoverEvents && !
scene->d_func()->allItemsUseDefaultCursor
679 &&
scene->d_func()->cachedItemsUnderMouse.isEmpty()) {
680 scene->d_func()->cachedItemsUnderMouse =
scene->d_func()->itemsAtPosition(mouseEvent.
screenPos(),
704#if QT_CONFIG(rubberband)
708 QStyleOptionRubberBand
option;
715 tmp +=
rect.adjusted(-1, -1, 1, 1);
733 q->viewport()->update(rubberBandRegion(
q->viewport(), rubberBandRect));
740 if (!
event->buttons()) {
741 rubberBanding =
false;
743 if (!rubberBandRect.isNull()) {
744 rubberBandRect =
QRect();
750 QRect oldRubberband = rubberBandRect;
754 const QPoint ep =
event->position().toPoint();
756 qAbs(mp.x() - ep.
x()) + 1,
qAbs(mp.y() - ep.
y()) + 1);
760 oldRubberband = rubberBandRect;
767 q->viewport()->update(rubberBandRegion(
q->viewport(), rubberBandRect));
773 selectionArea.
addPolygon(
q->mapToScene(rubberBandRect));
776 scene->
setSelectionArea(selectionArea, rubberBandSelectionOperation, rubberBandSelectionMode,
q->viewportTransform());
779void QGraphicsViewPrivate::clearRubberBand()
787 q->viewport()->update(rubberBandRegion(
q->viewport(), rubberBandRect));
792 rubberBanding =
false;
794 if (!rubberBandRect.isNull()) {
795 rubberBandRect =
QRect();
867#if QT_CONFIG(draganddrop)
906 if (itemd->transformData)
909 }
while ((parentItem = itemd->parent));
915 return baseRect.toAlignedRect();
925 return r.toAlignedRect();
963{
return !(
r.left() >
width) && !(
r.right() < 0) && !(
r.top() >=
height) && !(
r.bottom() < 0); }
966{
return r.left() <= 0 &&
r.top() <= 0 &&
r.right() >=
width - 1 &&
r.bottom() >=
height - 1; }
970 if (
rect->isEmpty()) {
1006 clip =
r.toAlignedRect();
1007 }
else if (!
q->isTransformed()) {
1011 xform *=
q->viewportTransform();
1040 if (dontAdjustForAntialiasing)
1041 viewRect.
adjust(-1, -1, 1, 1);
1043 viewRect.adjust(-2, -2, 2, 2);
1047 for (
QRect viewRect : region) {
1048 if (dontAdjustForAntialiasing)
1049 viewRect.adjust(-1, -1, 1, 1);
1051 viewRect.adjust(-2, -2, 2, 2);
1152 if (simpleRectLookup) {
1153 return scene->
items(exposedRegionSceneBounds,
1163 adjustedRegion +=
r.adjusted(-1, -1, 1, 1);
1187 q->setInputMethodHints({ });
1200 q->setInputMethodHints({ });
1210 setViewport(
nullptr);
1211 setAcceptDrops(
true);
1226 setViewport(
nullptr);
1227 setAcceptDrops(
true);
1238 : QAbstractScrollArea(dd, parent)
1240 setViewport(
nullptr);
1241 setAcceptDrops(
true);
1255 d->scene->d_func()->views.removeAll(
this);
1256 delete d->lastDragDropEvent;
1267 baseSize +=
QSizeF(
d->frameWidth * 2,
d->frameWidth * 2);
1270 return QAbstractScrollArea::sizeHint();
1291 return d->renderHints;
1296 if (hints ==
d->renderHints)
1298 d->renderHints = hints;
1311 QPainter::RenderHints oldHints =
d->renderHints;
1313 if (oldHints !=
d->renderHints)
1332 return d->alignment;
1339 d->recalculateContentSize();
1364 return d->transformationAnchor;
1369 d->transformationAnchor = anchor;
1374 d->viewport->setMouseTracking(
true);
1396 return d->resizeAnchor;
1401 d->resizeAnchor = anchor;
1406 d->viewport->setMouseTracking(
true);
1430 return d->viewportUpdateMode;
1435 d->viewportUpdateMode =
mode;
1459 return d->optimizationFlags;
1464 d->optimizationFlags =
flags;
1475 d->optimizationFlags.setFlag(flag,
enabled);
1500 if (
d->dragMode ==
mode)
1503#if QT_CONFIG(rubberband)
1504 d->clearRubberBand();
1517 d->handScrolling =
false;
1524 d->hasStoredOriginalCursor =
false;
1530#if QT_CONFIG(rubberband)
1547 return d->rubberBandSelectionMode;
1552 d->rubberBandSelectionMode =
mode;
1567QRect QGraphicsView::rubberBandRect()
const
1573 return d->rubberBandRect;
1600 return d->cacheMode;
1605 if (
mode ==
d->cacheMode)
1607 d->cacheMode =
mode;
1632 d->mustResizeBackgroundPixmap =
true;
1634 }
else if (
d->mustResizeBackgroundPixmap) {
1637 d->mustResizeBackgroundPixmap =
false;
1639 d->backgroundPixmapExposed =
QRegion();
1667 d->backgroundPixmapExposed += viewRect;
1669 d->scene->update(
rect);
1687 return d->sceneInteractionAllowed;
1692 d->sceneInteractionAllowed = allowed;
1732 d->scene->d_func()->removeView(
this);
1733 d->connectedToScene =
false;
1740 d->scene->clearFocus();
1744 if ((
d->scene =
scene)) {
1747 d->updateSceneSlotReimplementedChecked =
false;
1748 d->scene->d_func()->addView(
this);
1749 d->recalculateContentSize();
1751 d->keepLastCenterPoint =
true;
1754 if (!
d->scene->d_func()->allItemsIgnoreHoverEvents
1755 || !
d->scene->d_func()->allItemsUseDefaultCursor) {
1756 d->viewport->setMouseTracking(
true);
1760 if (!
d->scene->d_func()->allItemsIgnoreTouchEvents)
1768 d->recalculateContentSize();
1771 d->updateInputMethodSensitivity();
1773 if (
d->scene && hasFocus())
1774 d->scene->setFocus();
1803 if (
d->hasSceneRect)
1804 return d->sceneRect;
1806 return d->scene->sceneRect();
1812 d->hasSceneRect = !
rect.isNull();
1813 d->sceneRect =
rect;
1814 d->recalculateContentSize();
1889 if (!
d->leftIndent) {
1890 if (isRightToLeft()) {
1892 horizontal += horizontalScrollBar()->minimum();
1893 horizontal += horizontalScrollBar()->maximum();
1894 horizontal -=
qRound(viewPoint.x() -
width / 2.0);
1895 horizontalScrollBar()->setValue(horizontal);
1897 horizontalScrollBar()->setValue(
qRound(viewPoint.x() -
width / 2.0));
1901 verticalScrollBar()->setValue(
qRound(viewPoint.y() -
height / 2.0));
1902 d->lastCenterPoint = oldCenterPoint;
1947 if (viewRect.left() <=
left + xmargin) {
1950 horizontalScrollBar()->setValue(
int(viewRect.left() - xmargin - 0.5));
1952 if (viewRect.right() >=
right - xmargin) {
1955 horizontalScrollBar()->setValue(
int(viewRect.right() -
width + xmargin + 0.5));
1957 if (viewRect.top() <=
top + ymargin) {
1960 verticalScrollBar()->setValue(
int(viewRect.top() - ymargin - 0.5));
1962 if (viewRect.bottom() >=
bottom - ymargin) {
1965 verticalScrollBar()->setValue(
int(viewRect.bottom() -
height + ymargin + 0.5));
2020 if (!
d->scene ||
rect.isNull())
2025 if (unity.isEmpty())
2027 scale(1 / unity.width(), 1 / unity.height());
2032 if (viewRect.isEmpty())
2041 switch (aspectRatioMode) {
2043 xratio = yratio =
qMin(xratio, yratio);
2046 xratio = yratio =
qMax(xratio, yratio);
2053 scale(xratio, yratio);
2126 targetRect = sourceRect;
2132 qreal xratio = targetRect.width() / sourceRect.
width();
2133 qreal yratio = targetRect.height() / sourceRect.
height();
2136 switch (aspectRatioMode) {
2138 xratio = yratio =
qMin(xratio, yratio);
2141 xratio = yratio =
qMax(xratio, yratio);
2150 QList<QGraphicsItem *> itemList =
d->scene->items(sourceScenePoly,
2153 int numItems = itemList.size();
2154 for (
int i = 0;
i < numItems; ++
i)
2155 itemArray[numItems -
i - 1] = itemList.at(
i);
2160 QTransform painterMatrix =
d->matrix * moveMatrix;
2162 .
translate(targetRect.left(), targetRect.top())
2163 .
scale(xratio, yratio)
2168 for (
int i = 0;
i < numItems; ++
i)
2169 itemArray[
i]->d_ptr->initStyleOption(&styleOptionArray[
i], painterMatrix, targetRect.toRect());
2176 path.addPolygon(sourceScenePoly);
2177 path.closeSubpath();
2184 QRectF sourceSceneRect = sourceScenePoly.boundingRect();
2189 delete [] itemArray;
2190 d->freeStyleOptionsArray(styleOptionArray);
2206 return QList<QGraphicsItem *>();
2207 return d->scene->items();
2228 return QList<QGraphicsItem *>();
2235 return d->scene->items(xinv.mapRect(
QRectF(
pos.x(),
pos.y(), 1, 1)),
2273 return QList<QGraphicsItem *>();
2304 return QList<QGraphicsItem *>();
2324 return QList<QGraphicsItem *>();
2344 const QList<QGraphicsItem *> itemsAtPos =
items(
pos);
2345 return itemsAtPos.isEmpty() ?
nullptr : itemsAtPos.first();
2369 p.
rx() +=
d->horizontalScroll();
2370 p.ry() +=
d->verticalScroll();
2371 return d->identityMatrix ?
p :
d->matrix.inverted().map(
p);
2390 if (!
rect.isValid())
2393 QPointF scrollOffset(
d->horizontalScroll(),
d->verticalScroll());
2395 QPointF tl = scrollOffset +
r.topLeft();
2397 QPointF br = scrollOffset +
r.bottomRight();
2398 QPointF bl = scrollOffset +
r.bottomLeft();
2401 if (!
d->identityMatrix) {
2403 poly[0] =
x.
map(tl);
2404 poly[1] =
x.map(
tr);
2405 poly[2] =
x.map(br);
2406 poly[3] =
x.map(bl);
2448 matrix *=
d->matrix.inverted();
2460 QPointF p =
d->identityMatrix ? point :
d->matrix.map(point);
2461 p.
rx() -=
d->horizontalScroll();
2462 p.ry() -=
d->verticalScroll();
2486 if (!
d->identityMatrix) {
2488 tl =
x.map(
rect.topLeft());
2490 br =
x.map(
rect.bottomRight());
2491 bl =
x.map(
rect.bottomLeft());
2493 tl =
rect.topLeft();
2495 br =
rect.bottomRight();
2496 bl =
rect.bottomLeft();
2498 QPointF scrollOffset(
d->horizontalScroll(),
d->verticalScroll());
2506 poly[1] =
tr.toPoint();
2508 poly[3] = bl.toPoint();
2558 if (
value.userType() == QMetaType::QRectF)
2560 else if (
value.userType() == QMetaType::QPointF)
2562 else if (
value.userType() == QMetaType::QRect)
2563 value =
d->mapRectFromScene(
value.toRect()).toRect();
2564 else if (
value.userType() == QMetaType::QPoint)
2585 return d->backgroundBrush;
2590 d->backgroundBrush =
brush;
2595 d->mustResizeBackgroundPixmap =
true;
2615 return d->foregroundBrush;
2620 d->foregroundBrush =
brush;
2641 QList<QRect> dirtyViewportRects;
2642 dirtyViewportRects.reserve(
d->dirtyRegion.rectCount() + rects.size());
2643 for (
const QRect &dirtyRect :
d->dirtyRegion)
2644 dirtyViewportRects += dirtyRect;
2646 d->dirtyBoundingRect =
QRect();
2656 bool redraw =
false;
2663 xrect.
adjust(-2, -2, 2, 2);
2665 xrect.adjust(-1, -1, 1, 1);
2668 dirtyViewportRects << xrect;
2671 for (
const QRect &
rect : std::as_const(dirtyViewportRects)) {
2674 if (!boundingRectUpdate) {
2675 updateRegion +=
rect;
2692 else if (boundingRectUpdate)
2708 if (!
d->hasSceneRect) {
2709 d->sceneRect =
rect;
2710 d->recalculateContentSize();
2726 qWarning(
"QGraphicsView::setupViewport: cannot initialize null widget");
2732 d->accelerateScrolling = !(isGLWidget);
2747 if ((
d->scene && (!
d->scene->d_func()->allItemsIgnoreHoverEvents
2748 || !
d->scene->d_func()->allItemsUseDefaultCursor))
2755 if (
d->scene && !
d->scene->d_func()->allItemsIgnoreTouchEvents)
2758#ifndef QT_NO_GESTURES
2760 const auto gestures =
d->scene->d_func()->grabbedGestures.keys();
2776 if (
d->sceneInteractionAllowed) {
2777 switch (
event->type()) {
2793 if (
event->isAccepted())
2807 return QAbstractScrollArea::event(
event);
2817 return QAbstractScrollArea::viewportEvent(
event);
2819 switch (
event->type()) {
2831 if (!
d->scene->d_func()->popupWidgets.isEmpty())
2832 d->scene->d_func()->removePopup(
d->scene->d_func()->popupWidgets.constFirst());
2836 if (
d->scene && isActiveWindow()) {
2843 if (!
event->spontaneous() &&
d->scene && isActiveWindow()) {
2855 if (!
d->scene->d_func()->popupWidgets.isEmpty())
2856 d->scene->d_func()->removePopup(
d->scene->d_func()->popupWidgets.constFirst());
2858 d->useLastMouseEvent =
false;
2865#if QT_CONFIG(tooltip)
2879 d->fullUpdatePending =
false;
2880 d->dirtyScrollOffset =
QPoint();
2885 if (!
d->updateSceneSlotReimplementedChecked) {
2886 d->updateSceneSlotReimplementedChecked =
true;
2888 if (
mo != &QGraphicsView::staticMetaObject) {
2889 if (
mo->indexOfSlot(
"updateScene(QList<QRectF>)")
2890 != QGraphicsView::staticMetaObject.indexOfSlot(
"updateScene(QList<QRectF>)")) {
2905 if (
d->scene &&
d->sceneInteractionAllowed) {
2917#ifndef QT_NO_GESTURES
2924 if (
d->scene &&
d->sceneInteractionAllowed) {
2936 return QAbstractScrollArea::viewportEvent(
event);
2939#ifndef QT_NO_CONTEXTMENU
2946 if (!
d->scene || !
d->sceneInteractionAllowed)
2949 d->mousePressViewPoint =
event->pos();
2950 d->mousePressScenePoint =
mapToScene(
d->mousePressViewPoint);
2951 d->mousePressScreenPoint =
event->globalPos();
2952 d->lastMouseMoveScenePoint =
d->mousePressScenePoint;
2953 d->lastMouseMoveScreenPoint =
d->mousePressScreenPoint;
2956 contextEvent.setWidget(
viewport());
2957 contextEvent.setScenePos(
d->mousePressScenePoint);
2958 contextEvent.setScreenPos(
d->mousePressScreenPoint);
2959 contextEvent.setModifiers(
event->modifiers());
2961 contextEvent.setAccepted(
event->isAccepted());
2962 contextEvent.setTimestamp(
event->timestamp());
2964 event->setAccepted(contextEvent.isAccepted());
2968#if QT_CONFIG(draganddrop)
2972void QGraphicsView::dropEvent(QDropEvent *
event)
2975 if (!
d->scene || !
d->sceneInteractionAllowed)
2980 d->populateSceneDragDropEvent(&sceneEvent,
event);
2986 event->setAccepted(sceneEvent.isAccepted());
2987 if (sceneEvent.isAccepted())
2988 event->setDropAction(sceneEvent.dropAction());
2990 delete d->lastDragDropEvent;
2991 d->lastDragDropEvent =
nullptr;
2997void QGraphicsView::dragEnterEvent(QDragEnterEvent *
event)
3000 if (!
d->scene || !
d->sceneInteractionAllowed)
3004 d->useLastMouseEvent =
false;
3008 d->populateSceneDragDropEvent(&sceneEvent,
event);
3011 d->storeDragDropEvent(&sceneEvent);
3017 if (sceneEvent.isAccepted()) {
3018 event->setAccepted(
true);
3019 event->setDropAction(sceneEvent.dropAction());
3026void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *
event)
3029 if (!
d->scene || !
d->sceneInteractionAllowed)
3031 if (!
d->lastDragDropEvent) {
3032 qWarning(
"QGraphicsView::dragLeaveEvent: drag leave received before drag enter");
3038 sceneEvent.setScenePos(
d->lastDragDropEvent->scenePos());
3039 sceneEvent.setScreenPos(
d->lastDragDropEvent->screenPos());
3040 sceneEvent.setButtons(
d->lastDragDropEvent->buttons());
3041 sceneEvent.setModifiers(
d->lastDragDropEvent->modifiers());
3042 sceneEvent.setPossibleActions(
d->lastDragDropEvent->possibleActions());
3043 sceneEvent.setProposedAction(
d->lastDragDropEvent->proposedAction());
3044 sceneEvent.setDropAction(
d->lastDragDropEvent->dropAction());
3045 sceneEvent.setMimeData(
d->lastDragDropEvent->mimeData());
3046 sceneEvent.setWidget(
d->lastDragDropEvent->widget());
3047 sceneEvent.setSource(
d->lastDragDropEvent->source());
3048 delete d->lastDragDropEvent;
3049 d->lastDragDropEvent =
nullptr;
3055 if (sceneEvent.isAccepted())
3056 event->setAccepted(
true);
3062void QGraphicsView::dragMoveEvent(QDragMoveEvent *
event)
3065 if (!
d->scene || !
d->sceneInteractionAllowed)
3070 d->populateSceneDragDropEvent(&sceneEvent,
event);
3073 d->storeDragDropEvent(&sceneEvent);
3079 event->setAccepted(sceneEvent.isAccepted());
3080 if (sceneEvent.isAccepted())
3081 event->setDropAction(sceneEvent.dropAction());
3091 d->updateInputMethodSensitivity();
3092 QAbstractScrollArea::focusInEvent(
event);
3096 if (!
d->scene || !
event->isAccepted())
3097 QAbstractScrollArea::focusInEvent(
event);
3105 return QAbstractScrollArea::focusNextPrevChild(
next);
3114 QAbstractScrollArea::focusOutEvent(
event);
3125 if (!
d->scene || !
d->sceneInteractionAllowed) {
3126 QAbstractScrollArea::keyPressEvent(
event);
3130 if (!
event->isAccepted())
3131 QAbstractScrollArea::keyPressEvent(
event);
3140 if (!
d->scene || !
d->sceneInteractionAllowed)
3143 if (!
event->isAccepted())
3144 QAbstractScrollArea::keyReleaseEvent(
event);
3153 if (!
d->scene || !
d->sceneInteractionAllowed)
3156 d->storeMouseEvent(
event);
3157 d->mousePressViewPoint =
event->position().toPoint();
3158 d->mousePressScenePoint =
mapToScene(
d->mousePressViewPoint);
3159 d->mousePressScreenPoint =
event->globalPosition().toPoint();
3160 d->lastMouseMoveScenePoint =
d->mousePressScenePoint;
3161 d->lastMouseMoveScreenPoint =
d->mousePressScreenPoint;
3162 d->mousePressButton =
event->button();
3179 if (
event->spontaneous())
3185 const bool isAccepted = mouseEvent.
isAccepted();
3186 event->setAccepted(isAccepted);
3189 d->lastMouseEvent.setAccepted(isAccepted);
3202 d->storeMouseEvent(
event);
3203 d->lastMouseEvent.setAccepted(
false);
3205 if (
d->sceneInteractionAllowed) {
3207 d->mousePressViewPoint =
event->position().toPoint();
3208 d->mousePressScenePoint =
mapToScene(
d->mousePressViewPoint);
3209 d->mousePressScreenPoint =
event->globalPosition().toPoint();
3210 d->lastMouseMoveScenePoint =
d->mousePressScenePoint;
3211 d->lastMouseMoveScreenPoint =
d->mousePressScreenPoint;
3212 d->mousePressButton =
event->button();
3231 if (
event->spontaneous())
3238 event->setAccepted(isAccepted);
3241 d->lastMouseEvent.setAccepted(isAccepted);
3248#if QT_CONFIG(rubberband)
3250 if (
d->sceneInteractionAllowed) {
3253 d->rubberBanding =
true;
3254 d->rubberBandRect =
QRect();
3258 if (extendSelection) {
3262 d->scene->clearSelection();
3271 d->handScrolling =
true;
3272 d->handScrollMotions = 0;
3287 if (
d->handScrolling) {
3290 QPoint delta =
event->position().toPoint() -
d->lastMouseEvent.position().toPoint();
3291 hBar->setValue(hBar->value() + (isRightToLeft() ? delta.
x() : -delta.
x()));
3292 vBar->setValue(vBar->value() - delta.
y());
3296 ++
d->handScrollMotions;
3300 d->mouseMoveEventHandler(
event);
3310#if QT_CONFIG(rubberband)
3312 d->clearRubberBand();
3322 d->handScrolling =
false;
3324 if (
d->scene &&
d->sceneInteractionAllowed && !
d->lastMouseEvent.isAccepted() &&
d->handScrollMotions <= 6) {
3328 d->scene->clearSelection();
3332 d->storeMouseEvent(
event);
3334 if (!
d->sceneInteractionAllowed)
3355 if (
event->spontaneous())
3361 d->lastMouseEvent.setAccepted(mouseEvent.
isAccepted());
3366 d->_q_unsetViewportCursor();
3371#if QT_CONFIG(wheelevent)
3375void QGraphicsView::wheelEvent(QWheelEvent *
event)
3378 if (!
d->scene || !
d->sceneInteractionAllowed) {
3379 QAbstractScrollArea::wheelEvent(
event);
3388 wheelEvent.setScreenPos(
event->globalPosition().toPoint());
3389 wheelEvent.setButtons(
event->buttons());
3390 wheelEvent.setModifiers(
event->modifiers());
3391 const bool horizontal =
qAbs(
event->angleDelta().x()) >
qAbs(
event->angleDelta().y());
3392 wheelEvent.setDelta(horizontal ?
event->angleDelta().x() :
event->angleDelta().
y());
3393 wheelEvent.setPixelDelta(
event->pixelDelta());
3394 wheelEvent.setPhase(
event->phase());
3395 wheelEvent.setInverted(
event->isInverted());
3397 wheelEvent.setAccepted(
false);
3398 wheelEvent.setTimestamp(
event->timestamp());
3400 event->setAccepted(wheelEvent.isAccepted());
3401 if (!
event->isAccepted())
3402 QAbstractScrollArea::wheelEvent(
event);
3413 QAbstractScrollArea::paintEvent(
event);
3421 d->exposedRegion =
event->region();
3422 QRectF exposedSceneRect =
mapToScene(
d->exposedRegion.boundingRect()).boundingRect();
3426#if QT_CONFIG(rubberband)
3427 if (
d->rubberBanding && !
d->rubberBandRect.isEmpty())
3436 if (viewTransformed)
3440 const auto actuallyDraw = [&]() {
3445 if (
d->mustResizeBackgroundPixmap) {
3446 const qreal dpr =
d->viewport->devicePixelRatio();
3448 d->backgroundPixmap.setDevicePixelRatio(
dpr);
3453 p.fillRect(0, 0,
d->backgroundPixmap.width(),
d->backgroundPixmap.height(), bgBrush);
3455 d->mustResizeBackgroundPixmap =
false;
3459 if (!
d->backgroundPixmapExposed.isEmpty()) {
3460 QPainter backgroundPainter(&
d->backgroundPixmap);
3461 backgroundPainter.setClipRegion(
d->backgroundPixmapExposed,
Qt::ReplaceClip);
3462 if (viewTransformed)
3463 backgroundPainter.setTransform(viewTransform);
3464 QRectF backgroundExposedSceneRect =
mapToScene(
d->backgroundPixmapExposed.boundingRect()).boundingRect();
3466 d->backgroundPixmapExposed =
QRegion();
3470 if (viewTransformed) {
3488 const quint32 oldRectAdjust =
d->scene->d_func()->rectAdjust;
3490 d->scene->d_func()->rectAdjust = 1;
3492 d->scene->d_func()->rectAdjust = 2;
3493 d->scene->d_func()->drawItems(&
painter, viewTransformed ? &viewTransform :
nullptr,
3495 d->scene->d_func()->rectAdjust = oldRectAdjust;
3502 if (!
d->scene->d_func()->painterStateProtection)
3507 if (!
d->scene->d_func()->unpolishedItems.isEmpty())
3508 d->scene->d_func()->_q_polishItems();
3511 d->scene->d_func()->updateAll =
false;
3514 bool allItems =
false;
3515 QList<QGraphicsItem *> itemList =
d->findItems(
d->exposedRegion, &allItems, viewTransform);
3516 if (!itemList.isEmpty()) {
3518 const int numItems = itemList.size();
3522 for (
int i = 0;
i < numItems; ++
i) {
3525 itemd->
initStyleOption(&styleOptionArray[
i], viewTransform,
d->exposedRegion, allItems);
3532 if (!itemd->itemIsUntransformable()) {
3534 if (viewTransformed)
3539 itemd->paintedViewBoundingRects.insert(
d->viewport,
transform.mapRect(brect).toRect());
3543 d->freeStyleOptionsArray(styleOptionArray);
3550 #if QT_CONFIG(rubberband)
3552 if (
d->rubberBanding && !
d->rubberBandRect.isEmpty()) {
3554 QStyleOptionRubberBand
option;
3556 option.rect =
d->rubberBandRect;
3573 if (
d->stereoEnabled) {
3575 if (
w->toggleStereoTargetBuffer()) {
3577 w->toggleStereoTargetBuffer();
3584 d->scene->d_func()->painterStateProtection =
true;
3595 QPointF oldLastCenterPoint =
d->lastCenterPoint;
3597 QAbstractScrollArea::resizeEvent(
event);
3598 d->recalculateContentSize();
3601 if (
d->resizeAnchor ==
NoAnchor && !
d->keepLastCenterPoint) {
3602 d->updateLastCenterPoint();
3604 d->lastCenterPoint = oldLastCenterPoint;
3606 d->centerView(
d->resizeAnchor);
3607 d->keepLastCenterPoint =
false;
3611 d->mustResizeBackgroundPixmap =
true;
3621 d->dirtyScroll =
true;
3622 if (
d->transforming)
3624 if (isRightToLeft())
3629 if (
d->accelerateScrolling) {
3630#if QT_CONFIG(rubberband)
3632 if (!
d->rubberBandRect.isEmpty()) {
3634 rubberBandRegion += rubberBandRegion.translated(-dx, -dy);
3635 viewport()->update(rubberBandRegion);
3638 d->dirtyScrollOffset.rx() += dx;
3639 d->dirtyScrollOffset.ry() += dy;
3640 d->dirtyRegion.translate(dx, dy);
3650 d->updateLastCenterPoint();
3655 const qreal dpr =
d->backgroundPixmap.devicePixelRatio();
3660 if (!
d->backgroundPixmap.isNull())
3661 d->backgroundPixmap.scroll(dx *
dpr, dy *
dpr,
d->backgroundPixmap.rect(), &exposed);
3664 d->backgroundPixmapExposed.
translate(dx, dy);
3666 d->backgroundPixmapExposed += exposedScaled;
3670 if (
d->sceneInteractionAllowed)
3671 d->replayLastMouseEvent();
3680 d->recalculateContentSize();
3681 d->centerView(
d->transformationAnchor);
3682 QAbstractScrollArea::showEvent(
event);
3715 if (
d->scene &&
d->backgroundBrush.style() ==
Qt::NoBrush) {
3748 if (
d->scene &&
d->foregroundBrush.style() ==
Qt::NoBrush) {
3805 return d->identityMatrix ? moveMatrix :
d->matrix * moveMatrix;
3819 return !
d->identityMatrix ||
d->horizontalScroll() ||
d->verticalScroll();
3856 if (oldMatrix ==
d->matrix)
3860 d->transforming =
true;
3862 d->recalculateContentSize();
3863 d->centerView(
d->transformationAnchor);
3865 d->updateLastCenterPoint();
3868 if (
d->sceneInteractionAllowed)
3869 d->replayLastMouseEvent();
3870 d->transforming =
false;
3905 poly[0] =
x.
map(tl);
3906 poly[1] =
x.map(
tr);
3907 poly[2] =
x.map(br);
3908 poly[3] =
x.map(bl);
3915 return poly.boundingRect();
3920#include "moc_qgraphicsview.cpp"
static QWidget * activeModalWidget()
Returns the active modal widget.
static QWidget * activePopupWidget()
Returns the active popup widget.
int startDragDistance
the minimum distance required for a drag and drop operation to start.
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or \nullptr if no applica...
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QCursor class provides a mouse cursor with an arbitrary shape.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
virtual void setAccepted(bool accepted)
@ GraphicsSceneContextMenu
@ GraphicsSceneMouseRelease
@ GraphicsSceneMousePress
@ GraphicsSceneMouseDoubleClick
The QFocusEvent class contains event parameters for widget focus events.
The QGestureEvent class provides the description of triggered gestures.
void setWidget(QWidget *widget)
void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems=false) const
bool itemIsUntransformable() const
quint32 sceneTransformTranslateOnly
bool hasTranslateOnlySceneTransform()
QTransform sceneTransform
virtual bool isProxyWidget() const
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
QTransform deviceTransform(const QTransform &viewportTransform) const
QScopedPointer< QGraphicsItemPrivate > d_ptr
QPainterPath clipPath() const
virtual QPainterPath shape() const
Returns the shape of this item as a QPainterPath in local coordinates.
QRectF sceneBoundingRect() const
Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with bound...
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
QCursor cursor() const
Returns the current cursor shape for the item.
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
bool isClipped() const
Returns true if this item is clipped.
bool hasCursor() const
Returns true if this item has a cursor set; otherwise, false is returned.
QTransform sceneTransform() const
QRegion boundingRegion(const QTransform &itemToDeviceTransform) const
Qt::InputMethodHints inputMethodHints() const
Returns the current input method hints of this item.
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
void setButtons(Qt::MouseButtons buttons)
void setMimeData(const QMimeData *data)
void setPossibleActions(Qt::DropActions actions)
void setProposedAction(Qt::DropAction action)
void setModifiers(Qt::KeyboardModifiers modifiers)
void setDropAction(Qt::DropAction action)
This function lets the receiver of the drop set the drop action that was performed to action,...
void setSource(QWidget *source)
void setScreenPos(const QPoint &pos)
void setScenePos(const QPointF &pos)
The QGraphicsSceneEvent class provides a base class for all graphics view related events.
void setWidget(QWidget *widget)
void setTimestamp(quint64 ts)
QWidget * widget() const
Returns the widget where the event originated, or \nullptr if the event originates from another appli...
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
void setScenePos(const QPointF &pos)
void setScreenPos(const QPoint &pos)
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void setFlags(Qt::MouseEventFlags)
void setLastScenePos(const QPointF &pos)
void setButton(Qt::MouseButton button)
void setScenePos(const QPointF &pos)
QPoint screenPos() const
Returns the mouse cursor position in screen coordinates.
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent.
void setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
void setButtons(Qt::MouseButtons buttons)
QPointF scenePos() const
Returns the mouse cursor position in scene coordinates.
void setModifiers(Qt::KeyboardModifiers modifiers)
void setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
void setLastScreenPos(const QPoint &pos)
void setSource(Qt::MouseEventSource source)
void setScreenPos(const QPoint &pos)
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
QList< QGraphicsItem * > items(Qt::SortOrder order=Qt::DescendingOrder) const
Returns an ordered list of all items on the scene.
QRectF sceneRect
the scene rectangle; the bounding rectangle of the scene
void setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform)
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene's current focus item, or \nullptr if no it...
QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const
void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event)
void replayLastMouseEvent()
QPointF mousePressScenePoint
QMutableSinglePointEvent lastMouseEvent
void freeStyleOptionsArray(QStyleOptionGraphicsItem *array)
quint32 useLastMouseEvent
bool hasStoredOriginalCursor
quint32 mustAllocateStyleOptions
void updateInputMethodSensitivity()
QPointer< QGraphicsScene > scene
bool updateRegion(const QRectF &rect, const QTransform &xform)
QGraphicsView::DragMode dragMode
bool updateRect(const QRect &rect)
void _q_setViewportCursor(const QCursor &cursor)
quint32 sceneInteractionAllowed
qint64 horizontalScroll() const
QPoint mousePressScreenPoint
bool updateRectF(const QRectF &rect)
quint32 mustResizeBackgroundPixmap
QGraphicsView::ViewportUpdateMode viewportUpdateMode
static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent)
QGraphicsView::OptimizationFlags optimizationFlags
qint64 verticalScroll() const
QRectF mapRectToScene(const QRect &rect) const
QList< QStyleOptionGraphicsItem > styleOptions
QList< QGraphicsItem * > findItems(const QRegion &exposedRegion, bool *allItems, const QTransform &viewTransform) const
QRectF mapRectFromScene(const QRectF &rect) const
void updateLastCenterPoint()
void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest, QDropEvent *source)
QPointF mapToScene(const QPointF &point) const
void mouseMoveEventHandler(QMouseEvent *event)
QStyleOptionGraphicsItem * allocStyleOptionsArray(int numItems)
void recalculateContentSize()
void processPendingUpdates()
void _q_unsetViewportCursor()
quint32 fullUpdatePending
QGraphicsSceneDragDropEvent * lastDragDropEvent
void centerView(QGraphicsView::ViewportAnchor anchor)
QPoint mousePressViewPoint
QPoint lastMouseMoveScreenPoint
bool canStartScrollingAt(const QPoint &startPos) const override
QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const
QPointF lastMouseMoveScenePoint
QPointF lastRubberbandScenePoint
void storeMouseEvent(QMouseEvent *event)
Qt::MouseButton mousePressButton
void setUpdateClip(QGraphicsItem *)
QGraphicsView::CacheMode cacheMode
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
QPainter::RenderHints renderHints
the default render hints for the view
void mousePressEvent(QMouseEvent *event) override
\reimp
void setInteractive(bool allowed)
void shear(qreal sh, qreal sv)
Shears the current view transformation by (sh, sv).
QPointF mapToScene(const QPoint &point) const
Returns the viewport coordinate point mapped to scene coordinates.
void mouseMoveEvent(QMouseEvent *event) override
\reimp
QSize sizeHint() const override
\reimp
QList< QGraphicsItem * > items() const
Returns a list of all the items in the associated scene, in descending stacking order (i....
void setResizeAnchor(ViewportAnchor anchor)
void updateScene(const QList< QRectF > &rects)
Schedules an update of the scene rectangles rects.
void centerOn(const QPointF &pos)
Scrolls the contents of the viewport to ensure that the scene coordinate pos, is centered in the view...
void focusInEvent(QFocusEvent *event) override
\reimp
void updateSceneRect(const QRectF &rect)
Notifies QGraphicsView that the scene's scene rect has changed.
void setForegroundBrush(const QBrush &brush)
ViewportUpdateMode viewportUpdateMode
how the viewport should update its contents.
void setTransform(const QTransform &matrix, bool combine=false)
Sets the view's current transformation matrix to matrix.
bool isInteractive() const
void resetCachedContent()
Resets any cached content.
void setDragMode(DragMode mode)
QBrush backgroundBrush
the background brush of the scene.
void setRenderHints(QPainter::RenderHints hints)
void contextMenuEvent(QContextMenuEvent *event) override
\reimp
void setBackgroundBrush(const QBrush &brush)
void translate(qreal dx, qreal dy)
Translates the current view transformation by (dx, dy).
void setOptimizationFlag(OptimizationFlag flag, bool enabled=true)
Enables flag if enabled is true; otherwise disables flag.
Qt::Alignment alignment
the alignment of the scene in the view when the whole scene is visible.
bool isTransformed() const
void setupViewport(QWidget *widget) override
This slot is called by QAbstractScrollArea after setViewport() has been called.
QTransform transform() const
Returns the current transformation matrix for the view.
void resetTransform()
Resets the view transformation to the identity matrix.
bool viewportEvent(QEvent *event) override
\reimp
bool event(QEvent *event) override
\reimp
void scrollContentsBy(int dx, int dy) override
\reimp
void ensureVisible(const QRectF &rect, int xmargin=50, int ymargin=50)
Scrolls the contents of the viewport so that the scene rectangle rect is visible, with margins specif...
OptimizationFlags optimizationFlags
flags that can be used to tune QGraphicsView's performance.
bool focusNextPrevChild(bool next) override
\reimp
virtual void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[])
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
\reimp
void mouseDoubleClickEvent(QMouseEvent *event) override
\reimp
void paintEvent(QPaintEvent *event) override
\reimp
void inputMethodEvent(QInputMethodEvent *event) override
\reimp
QRectF sceneRect
the area of the scene visualized by this view.
void mouseReleaseEvent(QMouseEvent *event) override
\reimp
virtual void drawForeground(QPainter *painter, const QRectF &rect)
Draws the foreground of the scene using painter, after the background and all items are drawn.
void scale(qreal sx, qreal sy)
Scales the current view transformation by (sx, sy).
virtual void drawBackground(QPainter *painter, const QRectF &rect)
Draws the background of the scene using painter, before any items and the foreground are drawn.
void focusOutEvent(QFocusEvent *event) override
\reimp
void invalidateScene(const QRectF &rect=QRectF(), QGraphicsScene::SceneLayers layers=QGraphicsScene::AllLayers)
Invalidates and schedules a redraw of layers inside rect.
ViewportAnchor
This enums describe the possible anchors that QGraphicsView can use when the user resizes the view or...
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode=Qt::IgnoreAspectRatio)
Scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits insid...
void setCacheMode(CacheMode mode)
QTransform viewportTransform() const
Returns a matrix that maps scene coordinates to viewport coordinates.
ViewportAnchor transformationAnchor
how the view should position the scene during transformations.
void resizeEvent(QResizeEvent *event) override
\reimp
DragMode dragMode
the behavior for dragging the mouse over the scene while the left mouse button is pressed.
DragMode
This enum describes the default action for the view when pressing and dragging the mouse over the vie...
void setRenderHint(QPainter::RenderHint hint, bool enabled=true)
If enabled is true, the render hint hint is enabled; otherwise it is disabled.
~QGraphicsView()
Destructs the QGraphicsView object.
QGraphicsItem * itemAt(const QPoint &pos) const
Returns the item at position pos, which is in viewport coordinates.
void keyPressEvent(QKeyEvent *event) override
\reimp
void render(QPainter *painter, const QRectF &target=QRectF(), const QRect &source=QRect(), Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio)
Renders the source rect, which is in view coordinates, from the scene into target,...
void setScene(QGraphicsScene *scene)
Sets the current scene to scene.
@ BoundingRectViewportUpdate
@ DontAdjustForAntialiasing
void keyReleaseEvent(QKeyEvent *event) override
\reimp
void showEvent(QShowEvent *event) override
\reimp
QGraphicsView(QWidget *parent=nullptr)
Constructs a QGraphicsView.
ViewportAnchor resizeAnchor
how the view should position the scene when the view is resized.
QPoint mapFromScene(const QPointF &point) const
Returns the scene coordinate point to viewport coordinates.
void setTransformationAnchor(ViewportAnchor anchor)
QGraphicsScene * scene() const
Returns a pointer to the scene that is currently visualized in the view.
void setOptimizationFlags(OptimizationFlags flags)
void rotate(qreal angle)
Rotates the current view transformation angle degrees clockwise.
void setSceneRect(const QRectF &rect)
void setViewportUpdateMode(ViewportUpdateMode mode)
QBrush foregroundBrush
the foreground brush of the scene.
CacheMode cacheMode
which parts of the view are cached
void setAlignment(Qt::Alignment alignment)
QScreen * primaryScreen
the primary (or default) screen of the application.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
The QKeyEvent class describes a key event.
int key() const
Returns the code of the key that was pressed or released.
qsizetype size() const noexcept
qsizetype capacity() const
void reserve(qsizetype size)
void resize(qsizetype size)
static QMutableTouchEvent * from(QTouchEvent *e)
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
virtual int devType() const
The QPaintEvent class contains event parameters for paint events.
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
void closeSubpath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
The QPainter class performs low-level painting on widgets and other paint devices.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.
void restore()
Restores the current painter state (pops a saved state off the stack).
const QTransform & worldTransform() const
Returns the world transformation matrix.
void setOpacity(qreal opacity)
void save()
Saves the current painter state (pushes the state onto a stack).
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
RenderHint
Renderhints are used to specify flags to QPainter that may or may not be respected by any given engin...
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
void setRenderHints(RenderHints hints, bool on=true)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setTransform(const QTransform &transform, bool combine=false)
bool testRenderHint(RenderHint hint) const
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
constexpr qreal & rx() noexcept
Returns a reference to the x coordinate of this point.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
constexpr int & rx() noexcept
Returns a reference to the x coordinate of this point.
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
virtual void setAccepted(bool accepted) override
\reimp
The QPolygonF class provides a list of points using floating point precision.
The QPolygon class provides a list of points using integer precision.
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
\inmodule QtCore\reentrant
bool intersects(const QRect &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel...
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.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setRect(int x, int y, int w, int h) noexcept
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
int rectCount() const noexcept
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
The QResizeEvent class contains event parameters for resize events.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
The QShowEvent class provides an event that is sent when a widget is shown.
A base class for pointer events containing a single point, such as mouse events.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
constexpr QSizeF boundedTo(const QSizeF &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
The QStyleHintReturnMask class provides style hints that return a QRegion.
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
@ SH_ScrollView_FrameOnlyAroundContents
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...
QEventPoint & point(int touchId)
The QTouchEvent class contains parameters that describe a touch event.
Combined button and popup list for selecting options.
@ KeepAspectRatioByExpanding
@ IntersectsItemBoundingRect
constexpr Initialization Uninitialized
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
const EGLAttrib EGLOutputLayerEXT * layers
int qRound(qfloat16 d) noexcept
static QRectF adjustedItemEffectiveBoundingRect(const QGraphicsItem *item)
static bool intersectsViewport(const QRect &r, int width, int height)
static bool containsViewport(const QRect &r, int width, int height)
static void QRect_unite(QRect *rect, const QRect &other)
static const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD
QPainterPath qt_regionToPath(const QRegion ®ion)
QT_BEGIN_NAMESPACE bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
int q_round_bound(qreal d)
static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei GLsizei GLchar * source
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
static const QRectF boundingRect(const QPointF *points, int pointCount)
QPainterPath qt_regionToPath(const QRegion ®ion)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
obj metaObject() -> className()
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
app setAttribute(Qt::AA_DontShowIconsInMenus)