42 #ifndef QGRAPHICSVIEW_H 43 #define QGRAPHICSVIEW_H 45 #include <QtCore/qmetatype.h> 46 #include <QtGui/qpainter.h> 47 #include <QtGui/qscrollarea.h> 48 #include <QtGui/qgraphicsscene.h> 56 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW 67 Q_FLAGS(QPainter::RenderHints CacheMode OptimizationFlags)
73 Qt::Alignment alignment;
79 ViewportUpdateMode viewportUpdateMode;
80 #ifndef QT_NO_RUBBERBAND 104 enum ViewportUpdateMode {
109 BoundingRectViewportUpdate
113 DontClipPainter = 0x1,
114 DontSavePainterState = 0x2,
115 DontAdjustForAntialiasing = 0x4,
116 IndirectPainting = 0x8
126 QPainter::RenderHints renderHints()
const;
128 void setRenderHints(QPainter::RenderHints hints);
130 Qt::Alignment alignment()
const;
131 void setAlignment(Qt::Alignment alignment);
139 ViewportUpdateMode viewportUpdateMode()
const;
140 void setViewportUpdateMode(ViewportUpdateMode mode);
142 OptimizationFlags optimizationFlags()
const;
144 void setOptimizationFlags(OptimizationFlags flags);
149 #ifndef QT_NO_RUBBERBAND 154 CacheMode cacheMode()
const;
155 void setCacheMode(CacheMode mode);
156 void resetCachedContent();
158 bool isInteractive()
const;
159 void setInteractive(
bool allowed);
165 void setSceneRect(
const QRectF &rect);
169 void setMatrix(
const QMatrix &matrix,
bool combine =
false);
173 bool isTransformed()
const;
174 void setTransform(
const QTransform &matrix,
bool combine =
false);
175 void resetTransform();
181 void centerOn(
const QPointF &pos);
184 void ensureVisible(
const QRectF &rect,
int xmargin = 50,
int ymargin = 50);
185 inline void ensureVisible(
qreal x,
qreal y,
qreal w,
qreal h,
int xmargin = 50,
int ymargin = 50);
186 void ensureVisible(
const QGraphicsItem *item,
int xmargin = 50,
int ymargin = 50);
214 inline QPointF mapToScene(
int x,
int y)
const;
215 inline QPolygonF mapToScene(
int x,
int y,
int w,
int h)
const;
221 QBrush backgroundBrush()
const;
222 void setBackgroundBrush(
const QBrush &brush);
224 QBrush foregroundBrush()
const;
225 void setForegroundBrush(
const QBrush &brush);
230 void updateSceneRect(
const QRectF &rect);
240 #ifndef QT_NO_CONTEXTMENU 256 #ifndef QT_NO_WHEELEVENT 265 virtual void drawBackground(
QPainter *painter,
const QRectF &rect);
266 virtual void drawForeground(
QPainter *painter,
const QRectF &rect);
267 virtual void drawItems(
QPainter *painter,
int numItems,
278 friend class QGraphicsSceneWidget;
288 { setSceneRect(
QRectF(ax, ay, aw, ah)); }
292 { ensureVisible(
QRectF(ax, ay, aw, ah), xmargin, ymargin); }
294 { fitInView(
QRectF(ax, ay, w, h), mode); }
296 {
return items(
QPoint(ax, ay)); }
298 {
return items(
QRect(ax, ay, w, h), mode); }
300 {
return itemAt(
QPoint(ax, ay)); }
302 {
return mapToScene(
QPoint(ax, ay)); }
304 {
return mapToScene(
QRect(ax, ay, w, h)); }
306 {
return mapFromScene(
QPointF(ax, ay)); }
308 {
return mapFromScene(
QRectF(ax, ay, w, h)); }
310 #endif // QT_NO_GRAPHICSVIEW 316 #endif // QGRAPHICSVIEW_H The QVariant class acts like a union for the most common Qt data types.
The QPainter class performs low-level painting on widgets and other paint devices.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
DragMode
This enum describes the default action for the view when pressing and dragging the mouse over the vie...
The QKeyEvent class describes a key event.
The QCursor class provides a mouse cursor with an arbitrary shape.
QPointF mapToScene(const QPoint &point) const
Returns the viewport coordinate point mapped to scene coordinates.
OptimizationFlag
This enum describes flags that you can enable to improve rendering performance in QGraphicsView...
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
The QMatrix class specifies 2D transformations of a coordinate system.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
The QWheelEvent class contains parameters that describe a wheel event.
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Qt::ItemSelectionMode rubberBandSelectionMode
the behavior for selecting items with a rubber band selection rectangle.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
#define Q_PRIVATE_SLOT(d, signature)
The QPolygon class provides a vector of points using integer precision.
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
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 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...
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
The QPolygonF class provides a vector of points using floating point precision.
The QResizeEvent class contains event parameters for resize events.
QGraphicsItem * itemAt(const QPoint &pos) const
Returns the item at position pos, which is in viewport coordinates.
RenderHint
Renderhints are used to specify flags to QPainter that may or may not be respected by any given engin...
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
CacheModeFlag
This enum describes the flags that you can set for a QGraphicsView's cache mode.
The QShowEvent class provides an event that is sent when a widget is shown.
The QMouseEvent class contains parameters that describe a mouse event.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
QPoint mapFromScene(const QPointF &point) const
Returns the scene coordinate point to viewport coordinates.
OptimizationFlags optimizationFlags
flags that can be used to tune QGraphicsView's performance.
qreal angle(const QPointF &p1, const QPointF &p2)
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
The QSize class defines the size of a two-dimensional object using integer point precision.
#define Q_DECLARE_PRIVATE(Class)
QList< QGraphicsItem * > items() const
Returns a list of all the items in the associated scene, in descending stacking order (i...
void centerOn(const QPointF &pos)
Scrolls the contents of the viewport to ensure that the scene coordinate pos, is centered in the view...
The QPaintEvent class contains event parameters for paint events.
The QEvent class is the base class of all event classes.
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
The QFocusEvent class contains event parameters for widget focus events.
ViewportUpdateMode
This enum describes how QGraphicsView updates its viewport when the scene contents change or are expo...
The QList class is a template class that provides lists.
ViewportAnchor
This enums describe the possible anchors that QGraphicsView can use when the user resizes the view or...