Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qgraphicsview_p.h
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
4#ifndef QGRAPHICSVIEW_P_H
5#define QGRAPHICSVIEW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "qgraphicsview.h"
20
21#include <QtGui/private/qevent_p.h>
22#include <QtCore/qcoreapplication.h>
23#include "qgraphicssceneevent.h"
24#include <QtWidgets/qstyleoption.h>
25#include <private/qabstractscrollarea_p.h>
26#include <private/qapplication_p.h>
27
28QT_REQUIRE_CONFIG(graphicsview);
29
31
32class Q_WIDGETS_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
33{
34 Q_DECLARE_PUBLIC(QGraphicsView)
35public:
38
39 void recalculateContentSize();
40 void centerView(QGraphicsView::ViewportAnchor anchor);
41
42 QPainter::RenderHints renderHints;
43
45
61
63 void updateLastCenterPoint();
64
65 qint64 horizontalScroll() const;
66 qint64 verticalScroll() const;
67
68 QRectF mapRectToScene(const QRect &rect) const;
69 QRectF mapRectFromScene(const QRectF &rect) const;
70
82 qint64 scrollX, scrollY;
83 void updateScroll();
84 bool canStartScrollingAt(const QPoint &startPos) const override;
85
88
89 // Replaying mouse events
91 void replayLastMouseEvent();
92 void storeMouseEvent(QMouseEvent *event);
93 void mouseMoveEventHandler(QMouseEvent *event);
94
96 Qt::Alignment alignment;
97
101 QGraphicsView::OptimizationFlags optimizationFlags;
102
103 bool stereoEnabled = false; // Set in setupViewport()
104
106#if QT_CONFIG(rubberband)
107 QRect rubberBandRect;
108 QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
109 void updateRubberBand(const QMouseEvent *event);
110 void clearRubberBand();
111 bool rubberBanding;
112 Qt::ItemSelectionMode rubberBandSelectionMode;
113 Qt::ItemSelectionOperation rubberBandSelectionOperation;
114#endif
116
117 QGraphicsView::CacheMode cacheMode;
118
120 QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
121 void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
122
127
128#ifndef QT_NO_CURSOR
131 void _q_setViewportCursor(const QCursor &cursor);
132 void _q_unsetViewportCursor();
133#endif
134
136 void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
137 void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
138 QDropEvent *source);
139
140 QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
141 QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
144 void processPendingUpdates();
145 inline void updateAll()
146 {
147 viewport->update();
148 fullUpdatePending = true;
149 dirtyBoundingRect = QRect();
150 dirtyRegion = QRegion();
151 }
152
154 {
155 if (qt_widget_private(viewport)->shouldPaintOnScreen())
157 else
159 }
160
161 void setUpdateClip(QGraphicsItem *);
162
163 inline bool updateRectF(const QRectF &rect)
164 {
165 if (rect.isEmpty())
166 return false;
167 if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
168 return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
169 return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
170 }
171
172 bool updateRect(const QRect &rect);
173 bool updateRegion(const QRectF &rect, const QTransform &xform);
176
177 QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
178 const QTransform &viewTransform) const;
179
180 QPointF mapToScene(const QPointF &point) const;
181 QRectF mapToScene(const QRectF &rect) const;
182 static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
183 void updateInputMethodSensitivity();
184};
185
187
188#endif
\inmodule QtGui
Definition qbrush.h:30
static void sendPostedEvents(QObject *receiver=nullptr, int event_type=0)
Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent(...
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
@ UpdateRequest
Definition qcoreevent.h:113
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
QMutableSinglePointEvent lastMouseEvent
Qt::Alignment alignment
QPointer< QGraphicsScene > scene
QGraphicsView::DragMode dragMode
bool updateRectF(const QRectF &rect)
QGraphicsView::ViewportUpdateMode viewportUpdateMode
QGraphicsView::OptimizationFlags optimizationFlags
QGraphicsView::ViewportAnchor resizeAnchor
QList< QStyleOptionGraphicsItem > styleOptions
QGraphicsView::ViewportAnchor transformationAnchor
QGraphicsSceneDragDropEvent * lastDragDropEvent
QPainter::RenderHints renderHints
Qt::MouseButton mousePressButton
QGraphicsView::CacheMode cacheMode
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
ViewportAnchor
This enums describe the possible anchors that QGraphicsView can use when the user resizes the view or...
DragMode
This enum describes the default action for the view when pressing and dragging the mouse over the vie...
Definition qlist.h:74
\inmodule QtGui
Definition qevent.h:195
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:916
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
QCursor cursor
rect
[4]
Combined button and popup list for selecting options.
MouseButton
Definition qnamespace.h:55
ItemSelectionOperation
ItemSelectionMode
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLenum array
#define QT_REQUIRE_CONFIG(feature)
unsigned int quint32
Definition qtypes.h:45
long long qint64
Definition qtypes.h:55
double qreal
Definition qtypes.h:92
Q_WIDGETS_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
QGraphicsItem * item
view viewport() -> scroll(dx, dy, deviceRect)