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
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
28#include <QtCore/qpointer.h>
29
30QT_REQUIRE_CONFIG(graphicsview);
31
33
34class Q_WIDGETS_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
35{
36 Q_DECLARE_PUBLIC(QGraphicsView)
37public:
40
41 void recalculateContentSize();
42 void centerView(QGraphicsView::ViewportAnchor anchor);
43
44 QPainter::RenderHints renderHints;
45
47
63
65 void updateLastCenterPoint();
66
67 qint64 horizontalScroll() const;
68 qint64 verticalScroll() const;
69
70 QRectF mapRectToScene(const QRect &rect) const;
71 QRectF mapRectFromScene(const QRectF &rect) const;
72
84 qint64 scrollX, scrollY;
85 void updateScroll();
86 bool canStartScrollingAt(const QPoint &startPos) const override;
87
90
91 // Replaying mouse events
93 void replayLastMouseEvent();
94 void storeMouseEvent(QMouseEvent *event);
95 void mouseMoveEventHandler(QMouseEvent *event);
96
98 Qt::Alignment alignment;
99
103 QGraphicsView::OptimizationFlags optimizationFlags;
104
105 bool stereoEnabled = false; // Set in setupViewport()
106
107 QPointer<QGraphicsScene> scene;
108#if QT_CONFIG(rubberband)
109 QRect rubberBandRect;
110 QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
111 void updateRubberBand(const QMouseEvent *event);
112 void clearRubberBand();
113 bool rubberBanding;
114 Qt::ItemSelectionMode rubberBandSelectionMode;
115 Qt::ItemSelectionOperation rubberBandSelectionOperation;
116#endif
118
119 QGraphicsView::CacheMode cacheMode;
120
121 QList<QStyleOptionGraphicsItem> styleOptions;
122 QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
123 void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
124
129
130#ifndef QT_NO_CURSOR
133 void _q_setViewportCursor(const QCursor &cursor);
134 void _q_unsetViewportCursor();
135#endif
136
138 void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
139 void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
140 QDropEvent *source);
141
142 QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
143 QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
146 void processPendingUpdates();
147 inline void updateAll()
148 {
149 viewport->update();
150 fullUpdatePending = true;
151 dirtyBoundingRect = QRect();
152 dirtyRegion = QRegion();
153 }
154
162
163 void setUpdateClip(QGraphicsItem *);
164
165 inline bool updateRectF(const QRectF &rect)
166 {
167 if (rect.isEmpty())
168 return false;
169 if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
170 return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
171 return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
172 }
173
174 bool updateRect(const QRect &rect);
175 bool updateRegion(const QRectF &rect, const QTransform &xform);
178
179 QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
180 const QTransform &viewTransform) const;
181
182 QPointF mapToScene(const QPointF &point) const;
183 QRectF mapToScene(const QRectF &rect) const;
184 static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
185 void updateInputMethodSensitivity();
186};
187
189
190#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...
\inmodule QtGui
Definition qevent.h:196
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:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\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:917
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:56
ItemSelectionOperation
ItemSelectionMode
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLenum array
#define QT_REQUIRE_CONFIG(feature)
unsigned int quint32
Definition qtypes.h:50
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
Q_WIDGETS_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
QGraphicsItem * item
view viewport() -> scroll(dx, dy, deviceRect)