27 Q_FLAGS(QPainter::RenderHints CacheMode OptimizationFlags)
28 Q_PROPERTY(QBrush backgroundBrush READ backgroundBrush WRITE setBackgroundBrush)
29 Q_PROPERTY(QBrush foregroundBrush READ foregroundBrush WRITE setForegroundBrush)
30 Q_PROPERTY(
bool interactive READ isInteractive WRITE setInteractive)
31 Q_PROPERTY(QRectF sceneRect READ sceneRect WRITE setSceneRect)
32 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
33 Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
34 Q_PROPERTY(DragMode dragMode READ dragMode WRITE setDragMode)
35 Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode)
36 Q_PROPERTY(ViewportAnchor transformationAnchor READ transformationAnchor
37 WRITE setTransformationAnchor)
38 Q_PROPERTY(ViewportAnchor resizeAnchor READ resizeAnchor WRITE setResizeAnchor)
39 Q_PROPERTY(ViewportUpdateMode viewportUpdateMode READ viewportUpdateMode
40 WRITE setViewportUpdateMode)
41#if QT_CONFIG(rubberband)
42 Q_PROPERTY(Qt::ItemSelectionMode rubberBandSelectionMode READ rubberBandSelectionMode
43 WRITE setRubberBandSelectionMode)
45 Q_PROPERTY(OptimizationFlags optimizationFlags READ optimizationFlags
46 WRITE setOptimizationFlags)
54 Q_ENUM(ViewportAnchor)
60 Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)
69 enum ViewportUpdateMode {
71 MinimalViewportUpdate,
74 BoundingRectViewportUpdate
76 Q_ENUM(ViewportUpdateMode)
78 enum OptimizationFlag {
79 DontSavePainterState = 0x1,
80 DontAdjustForAntialiasing = 0x2,
81 IndirectPainting = 0x4
83 Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)
85 QGraphicsView(QWidget *parent =
nullptr);
86 QGraphicsView(QGraphicsScene *scene, QWidget *parent =
nullptr);
89 QSize sizeHint()
const override;
91 QPainter::RenderHints renderHints()
const;
92 void setRenderHint(QPainter::RenderHint hint,
bool enabled =
true);
93 void setRenderHints(QPainter::RenderHints hints);
95 Qt::Alignment alignment()
const;
96 void setAlignment(Qt::Alignment alignment);
98 ViewportAnchor transformationAnchor()
const;
99 void setTransformationAnchor(ViewportAnchor anchor);
101 ViewportAnchor resizeAnchor()
const;
102 void setResizeAnchor(ViewportAnchor anchor);
104 ViewportUpdateMode viewportUpdateMode()
const;
105 void setViewportUpdateMode(ViewportUpdateMode mode);
107 OptimizationFlags optimizationFlags()
const;
108 void setOptimizationFlag(OptimizationFlag flag,
bool enabled =
true);
109 void setOptimizationFlags(OptimizationFlags flags);
111 DragMode dragMode()
const;
112 void setDragMode(DragMode mode);
114#if QT_CONFIG(rubberband)
115 Qt::ItemSelectionMode rubberBandSelectionMode()
const;
116 void setRubberBandSelectionMode(Qt::ItemSelectionMode mode);
117 QRect rubberBandRect()
const;
120 CacheMode cacheMode()
const;
121 void setCacheMode(CacheMode mode);
122 void resetCachedContent();
124 bool isInteractive()
const;
125 void setInteractive(
bool allowed);
127 QGraphicsScene *scene()
const;
128 void setScene(QGraphicsScene *scene);
130 QRectF sceneRect()
const;
131 void setSceneRect(
const QRectF &rect);
132 inline void setSceneRect(qreal x, qreal y, qreal w, qreal h);
134 QTransform transform()
const;
135 QTransform viewportTransform()
const;
136 bool isTransformed()
const;
137 void setTransform(
const QTransform &matrix,
bool combine =
false);
138 void resetTransform();
139 void rotate(qreal angle);
140 void scale(qreal sx, qreal sy);
141 void shear(qreal sh, qreal sv);
142 void translate(qreal dx, qreal dy);
144 void centerOn(
const QPointF &pos);
145 inline void centerOn(qreal x, qreal y);
146 void centerOn(
const QGraphicsItem *item);
147 void ensureVisible(
const QRectF &rect,
int xmargin = 50,
int ymargin = 50);
148 inline void ensureVisible(qreal x, qreal y, qreal w, qreal h,
int xmargin = 50,
int ymargin = 50);
149 void ensureVisible(
const QGraphicsItem *item,
int xmargin = 50,
int ymargin = 50);
150 void fitInView(
const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
151 inline void fitInView(qreal x, qreal y, qreal w, qreal h,
152 Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
153 void fitInView(
const QGraphicsItem *item,
154 Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
156 void render(QPainter *painter,
const QRectF &target = QRectF(),
const QRect &source = QRect(),
157 Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
159 QList<QGraphicsItem *> items()
const;
160 QList<QGraphicsItem *> items(
const QPoint &pos)
const;
161 inline QList<QGraphicsItem *> items(
int x,
int y)
const;
162 QList<QGraphicsItem *> items(
const QRect &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape)
const;
163 inline QList<QGraphicsItem *> items(
int x,
int y,
int w,
int h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape)
const;
164 QList<QGraphicsItem *> items(
const QPolygon &polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape)
const;
165 QList<QGraphicsItem *> items(
const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape)
const;
166 QGraphicsItem *itemAt(
const QPoint &pos)
const;
167 inline QGraphicsItem *itemAt(
int x,
int y)
const;
169 QPointF mapToScene(
const QPoint &point)
const;
170 QPolygonF mapToScene(
const QRect &rect)
const;
171 QPolygonF mapToScene(
const QPolygon &polygon)
const;
172 QPainterPath mapToScene(
const QPainterPath &path)
const;
173 QPoint mapFromScene(
const QPointF &point)
const;
174 QPolygon mapFromScene(
const QRectF &rect)
const;
175 QPolygon mapFromScene(
const QPolygonF &polygon)
const;
176 QPainterPath mapFromScene(
const QPainterPath &path)
const;
177 inline QPointF mapToScene(
int x,
int y)
const;
178 inline QPolygonF mapToScene(
int x,
int y,
int w,
int h)
const;
179 inline QPoint mapFromScene(qreal x, qreal y)
const;
180 inline QPolygon mapFromScene(qreal x, qreal y, qreal w, qreal h)
const;
182 QVariant inputMethodQuery(Qt::InputMethodQuery query)
const override;
184 QBrush backgroundBrush()
const;
185 void setBackgroundBrush(
const QBrush &brush);
187 QBrush foregroundBrush()
const;
188 void setForegroundBrush(
const QBrush &brush);
191 void updateScene(
const QList<QRectF> &rects);
192 void invalidateScene(
const QRectF &rect = QRectF(), QGraphicsScene::SceneLayers layers = QGraphicsScene::AllLayers);
193 void updateSceneRect(
const QRectF &rect);
195#if QT_CONFIG(rubberband)
197 void rubberBandChanged(QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint);
201 void setupViewport(QWidget *widget) override;
204 QGraphicsView(QGraphicsViewPrivate &, QWidget *parent =
nullptr);
205 bool event(QEvent *event) override;
206 bool viewportEvent(QEvent *event) override;
208#ifndef QT_NO_CONTEXTMENU
209 void contextMenuEvent(QContextMenuEvent *event) override;
211#if QT_CONFIG(draganddrop)
212 void dragEnterEvent(QDragEnterEvent *event) override;
213 void dragLeaveEvent(QDragLeaveEvent *event) override;
214 void dragMoveEvent(QDragMoveEvent *event) override;
215 void dropEvent(QDropEvent *event) override;
217 void focusInEvent(QFocusEvent *event) override;
218 bool focusNextPrevChild(
bool next) override;
219 void focusOutEvent(QFocusEvent *event) override;
220 void keyPressEvent(QKeyEvent *event) override;
221 void keyReleaseEvent(QKeyEvent *event) override;
222 void mouseDoubleClickEvent(QMouseEvent *event) override;
223 void mousePressEvent(QMouseEvent *event) override;
224 void mouseMoveEvent(QMouseEvent *event) override;
225 void mouseReleaseEvent(QMouseEvent *event) override;
226#if QT_CONFIG(wheelevent)
227 void wheelEvent(QWheelEvent *event) override;
229 void paintEvent(QPaintEvent *event) override;
230 void resizeEvent(QResizeEvent *event) override;
231 void scrollContentsBy(
int dx,
int dy) override;
232 void showEvent(QShowEvent *event) override;
233 void inputMethodEvent(QInputMethodEvent *event) override;
235 virtual void drawBackground(QPainter *painter,
const QRectF &rect);
236 virtual void drawForeground(QPainter *painter,
const QRectF &rect);
237 virtual void drawItems(QPainter *painter,
int numItems,
238 QGraphicsItem *items[],
239 const QStyleOptionGraphicsItem options[]);
242 Q_DECLARE_PRIVATE(QGraphicsView)
243 Q_DISABLE_COPY(QGraphicsView)
245 Q_PRIVATE_SLOT(d_func(),
void _q_setViewportCursor(
const QCursor &))
246 Q_PRIVATE_SLOT(d_func(),
void _q_unsetViewportCursor())
248 friend class QGraphicsSceneWidget;
249 friend class QGraphicsScene;
250 friend class QGraphicsScenePrivate;
251 friend class QGraphicsItemPrivate;