Qt 4.8
qgraphicsitem.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGRAPHICSITEM_H
43 #define QGRAPHICSITEM_H
44 
45 #include <QtCore/qglobal.h>
46 #include <QtCore/qobject.h>
47 #include <QtCore/qvariant.h>
48 #include <QtCore/qrect.h>
49 #include <QtCore/qscopedpointer.h>
50 #include <QtGui/qpainterpath.h>
51 #include <QtGui/qpixmap.h>
52 
53 class tst_QGraphicsItem;
54 
56 
58 
59 QT_MODULE(Gui)
60 
61 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
62 
63 class QBrush;
64 class QCursor;
65 class QFocusEvent;
66 class QGraphicsEffect;
67 class QGraphicsItemGroup;
68 class QGraphicsObject;
75 class QGraphicsScene;
76 class QGraphicsTransform;
77 class QGraphicsWidget;
78 class QInputMethodEvent;
79 class QKeyEvent;
80 class QMatrix;
81 class QMenu;
82 class QPainter;
83 class QPen;
84 class QPointF;
85 class QRectF;
87 
90 {
91 public:
93  ItemIsMovable = 0x1,
95  ItemIsFocusable = 0x4,
96  ItemClipsToShape = 0x8,
97  ItemClipsChildrenToShape = 0x10,
98  ItemIgnoresTransformations = 0x20,
99  ItemIgnoresParentOpacity = 0x40,
100  ItemDoesntPropagateOpacityToChildren = 0x80,
101  ItemStacksBehindParent = 0x100,
102  ItemUsesExtendedStyleOption = 0x200,
103  ItemHasNoContents = 0x400,
104  ItemSendsGeometryChanges = 0x800,
105  ItemAcceptsInputMethod = 0x1000,
106  ItemNegativeZStacksBehindParent = 0x2000,
107  ItemIsPanel = 0x4000,
108  ItemIsFocusScope = 0x8000, // internal
109  ItemSendsScenePositionChanges = 0x10000,
110  ItemStopsClickFocusPropagation = 0x20000,
111  ItemStopsFocusHandling = 0x40000
112  // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
113  };
114  Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
115 
150  ItemTransformOriginPointHasChanged
151  };
152 
153  enum CacheMode {
156  DeviceCoordinateCache
157  };
158 
160  {
163  SceneModal
164  };
165 
166  QGraphicsItem(QGraphicsItem *parent = 0
167 #ifndef Q_QDOC
168  // ### obsolete argument
169  , QGraphicsScene *scene = 0
170 #endif
171  );
172  virtual ~QGraphicsItem();
173 
174  QGraphicsScene *scene() const;
175 
176  QGraphicsItem *parentItem() const;
177  QGraphicsItem *topLevelItem() const;
178  QGraphicsObject *parentObject() const;
179  QGraphicsWidget *parentWidget() const;
180  QGraphicsWidget *topLevelWidget() const;
181  QGraphicsWidget *window() const;
182  QGraphicsItem *panel() const;
183  void setParentItem(QGraphicsItem *parent);
184  QList<QGraphicsItem *> children() const; // ### obsolete
185  QList<QGraphicsItem *> childItems() const;
186  bool isWidget() const;
187  bool isWindow() const;
188  bool isPanel() const;
189 
190  QGraphicsObject *toGraphicsObject();
191  const QGraphicsObject *toGraphicsObject() const;
192 
193  QGraphicsItemGroup *group() const;
194  void setGroup(QGraphicsItemGroup *group);
195 
196  GraphicsItemFlags flags() const;
197  void setFlag(GraphicsItemFlag flag, bool enabled = true);
198  void setFlags(GraphicsItemFlags flags);
199 
200  CacheMode cacheMode() const;
201  void setCacheMode(CacheMode mode, const QSize &cacheSize = QSize());
202 
203  PanelModality panelModality() const;
204  void setPanelModality(PanelModality panelModality);
205  bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = 0) const;
206 
207 #ifndef QT_NO_TOOLTIP
208  QString toolTip() const;
209  void setToolTip(const QString &toolTip);
210 #endif
211 
212 #ifndef QT_NO_CURSOR
213  QCursor cursor() const;
214  void setCursor(const QCursor &cursor);
215  bool hasCursor() const;
216  void unsetCursor();
217 #endif
218 
219  bool isVisible() const;
220  bool isVisibleTo(const QGraphicsItem *parent) const;
221  void setVisible(bool visible);
222  inline void hide() { setVisible(false); }
223  inline void show() { setVisible(true); }
224 
225  bool isEnabled() const;
226  void setEnabled(bool enabled);
227 
228  bool isSelected() const;
229  void setSelected(bool selected);
230 
231  bool acceptDrops() const;
232  void setAcceptDrops(bool on);
233 
234  qreal opacity() const;
235  qreal effectiveOpacity() const;
236  void setOpacity(qreal opacity);
237 
238 #ifndef QT_NO_GRAPHICSEFFECT
239  // Effect
240  QGraphicsEffect *graphicsEffect() const;
241  void setGraphicsEffect(QGraphicsEffect *effect);
242 #endif //QT_NO_GRAPHICSEFFECT
243 
244  Qt::MouseButtons acceptedMouseButtons() const;
245  void setAcceptedMouseButtons(Qt::MouseButtons buttons);
246 
247  bool acceptsHoverEvents() const; // ### obsolete
248  void setAcceptsHoverEvents(bool enabled); // ### obsolete
249  bool acceptHoverEvents() const;
250  void setAcceptHoverEvents(bool enabled);
251  bool acceptTouchEvents() const;
252  void setAcceptTouchEvents(bool enabled);
253 
254  bool filtersChildEvents() const;
255  void setFiltersChildEvents(bool enabled);
256 
257  bool handlesChildEvents() const;
258  void setHandlesChildEvents(bool enabled);
259 
260  bool isActive() const;
261  void setActive(bool active);
262 
263  bool hasFocus() const;
264  void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason);
265  void clearFocus();
266 
267  QGraphicsItem *focusProxy() const;
268  void setFocusProxy(QGraphicsItem *item);
269 
270  QGraphicsItem *focusItem() const;
271  QGraphicsItem *focusScopeItem() const;
272 
273  void grabMouse();
274  void ungrabMouse();
275  void grabKeyboard();
276  void ungrabKeyboard();
277 
278  // Positioning in scene coordinates
279  QPointF pos() const;
280  inline qreal x() const { return pos().x(); }
281  void setX(qreal x);
282  inline qreal y() const { return pos().y(); }
283  void setY(qreal y);
284  QPointF scenePos() const;
285  void setPos(const QPointF &pos);
286  inline void setPos(qreal x, qreal y);
287  inline void moveBy(qreal dx, qreal dy) { setPos(pos().x() + dx, pos().y() + dy); }
288 
289  void ensureVisible(const QRectF &rect = QRectF(), int xmargin = 50, int ymargin = 50);
290  inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50);
291 
292  // Local transformation
293  QMatrix matrix() const;
294  QMatrix sceneMatrix() const;
295  void setMatrix(const QMatrix &matrix, bool combine = false);
296  void resetMatrix();
297  QTransform transform() const;
298  QTransform sceneTransform() const;
299  QTransform deviceTransform(const QTransform &viewportTransform) const;
300  QTransform itemTransform(const QGraphicsItem *other, bool *ok = 0) const;
301  void setTransform(const QTransform &matrix, bool combine = false);
302  void resetTransform();
303 
304  void rotate(qreal angle); // ### obsolete
305  void scale(qreal sx, qreal sy); // ### obsolete
306  void shear(qreal sh, qreal sv); // ### obsolete
307  void translate(qreal dx, qreal dy); // ### obsolete
308 
309  void setRotation(qreal angle);
310  qreal rotation() const;
311 
312  void setScale(qreal scale);
313  qreal scale() const;
314 
315  QList<QGraphicsTransform *> transformations() const;
316  void setTransformations(const QList<QGraphicsTransform *> &transformations);
317 
318  QPointF transformOriginPoint() const;
319  void setTransformOriginPoint(const QPointF &origin);
320  inline void setTransformOriginPoint(qreal ax, qreal ay)
321  { setTransformOriginPoint(QPointF(ax,ay)); }
322 
323  virtual void advance(int phase);
324 
325  // Stacking order
326  qreal zValue() const;
327  void setZValue(qreal z);
328  void stackBefore(const QGraphicsItem *sibling);
329 
330  // Hit test
331  virtual QRectF boundingRect() const = 0;
332  QRectF childrenBoundingRect() const;
333  QRectF sceneBoundingRect() const;
334  virtual QPainterPath shape() const;
335  bool isClipped() const;
336  QPainterPath clipPath() const;
337  virtual bool contains(const QPointF &point) const;
338  virtual bool collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
339  virtual bool collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
341  bool isObscured() const;
342  bool isObscured(const QRectF &rect) const; // ### Qt 5: merge with isObscured(), add QRectF arg to isObscuredBy()
343  inline bool isObscured(qreal x, qreal y, qreal w, qreal h) const;
344  virtual bool isObscuredBy(const QGraphicsItem *item) const;
345  virtual QPainterPath opaqueArea() const;
346 
347  QRegion boundingRegion(const QTransform &itemToDeviceTransform) const;
348  qreal boundingRegionGranularity() const;
349  void setBoundingRegionGranularity(qreal granularity);
350 
351  // Drawing
352  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
353  void update(const QRectF &rect = QRectF());
354  inline void update(qreal x, qreal y, qreal width, qreal height);
355  void scroll(qreal dx, qreal dy, const QRectF &rect = QRectF());
356 
357  // Coordinate mapping
358  QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const;
359  QPointF mapToParent(const QPointF &point) const;
360  QPointF mapToScene(const QPointF &point) const;
361  QPolygonF mapToItem(const QGraphicsItem *item, const QRectF &rect) const;
362  QPolygonF mapToParent(const QRectF &rect) const;
363  QPolygonF mapToScene(const QRectF &rect) const;
364  QRectF mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const;
365  QRectF mapRectToParent(const QRectF &rect) const;
366  QRectF mapRectToScene(const QRectF &rect) const;
367  QPolygonF mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const;
368  QPolygonF mapToParent(const QPolygonF &polygon) const;
369  QPolygonF mapToScene(const QPolygonF &polygon) const;
370  QPainterPath mapToItem(const QGraphicsItem *item, const QPainterPath &path) const;
371  QPainterPath mapToParent(const QPainterPath &path) const;
372  QPainterPath mapToScene(const QPainterPath &path) const;
373  QPointF mapFromItem(const QGraphicsItem *item, const QPointF &point) const;
374  QPointF mapFromParent(const QPointF &point) const;
375  QPointF mapFromScene(const QPointF &point) const;
376  QPolygonF mapFromItem(const QGraphicsItem *item, const QRectF &rect) const;
377  QPolygonF mapFromParent(const QRectF &rect) const;
378  QPolygonF mapFromScene(const QRectF &rect) const;
379  QRectF mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const;
380  QRectF mapRectFromParent(const QRectF &rect) const;
381  QRectF mapRectFromScene(const QRectF &rect) const;
382  QPolygonF mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const;
383  QPolygonF mapFromParent(const QPolygonF &polygon) const;
384  QPolygonF mapFromScene(const QPolygonF &polygon) const;
385  QPainterPath mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const;
386  QPainterPath mapFromParent(const QPainterPath &path) const;
387  QPainterPath mapFromScene(const QPainterPath &path) const;
388 
389  inline QPointF mapToItem(const QGraphicsItem *item, qreal x, qreal y) const;
390  inline QPointF mapToParent(qreal x, qreal y) const;
391  inline QPointF mapToScene(qreal x, qreal y) const;
392  inline QPolygonF mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
393  inline QPolygonF mapToParent(qreal x, qreal y, qreal w, qreal h) const;
394  inline QPolygonF mapToScene(qreal x, qreal y, qreal w, qreal h) const;
395  inline QRectF mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
396  inline QRectF mapRectToParent(qreal x, qreal y, qreal w, qreal h) const;
397  inline QRectF mapRectToScene(qreal x, qreal y, qreal w, qreal h) const;
398  inline QPointF mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const;
399  inline QPointF mapFromParent(qreal x, qreal y) const;
400  inline QPointF mapFromScene(qreal x, qreal y) const;
401  inline QPolygonF mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
402  inline QPolygonF mapFromParent(qreal x, qreal y, qreal w, qreal h) const;
403  inline QPolygonF mapFromScene(qreal x, qreal y, qreal w, qreal h) const;
404  inline QRectF mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
405  inline QRectF mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const;
406  inline QRectF mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const;
407 
408  bool isAncestorOf(const QGraphicsItem *child) const;
409  QGraphicsItem *commonAncestorItem(const QGraphicsItem *other) const;
410  bool isUnderMouse() const;
411 
412  // Custom data
413  QVariant data(int key) const;
414  void setData(int key, const QVariant &value);
415 
416  Qt::InputMethodHints inputMethodHints() const;
417  void setInputMethodHints(Qt::InputMethodHints hints);
418 
419  enum {
420  Type = 1,
421  UserType = 65536
422  };
423  virtual int type() const;
424 
425  void installSceneEventFilter(QGraphicsItem *filterItem);
426  void removeSceneEventFilter(QGraphicsItem *filterItem);
427 
428 protected:
429  void updateMicroFocus();
430  virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
431  virtual bool sceneEvent(QEvent *event);
432  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
433  virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
434  virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
435  virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
436  virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
437  virtual void focusInEvent(QFocusEvent *event);
438  virtual void focusOutEvent(QFocusEvent *event);
439  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
440  virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
441  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
442  virtual void keyPressEvent(QKeyEvent *event);
443  virtual void keyReleaseEvent(QKeyEvent *event);
444  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
445  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
446  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
447  virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
448  virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
449  virtual void inputMethodEvent(QInputMethodEvent *event);
450  virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
451 
452  virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
453 
454  enum Extension {
455  UserExtension = 0x80000000
456  };
457  virtual bool supportsExtension(Extension extension) const;
458  virtual void setExtension(Extension extension, const QVariant &variant);
459  virtual QVariant extension(const QVariant &variant) const;
460 
461 protected:
463  QGraphicsItem *parent, QGraphicsScene *scene);
465 
466  void addToIndex();
467  void removeFromIndex();
468  void prepareGeometryChange();
469 
470 private:
490 #ifndef QT_NO_GESTURES
491  friend class QGestureManager;
492 #endif
493  friend class ::tst_QGraphicsItem;
494  friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *);
495  friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *);
496 };
497 
498 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags)
499 Q_DECLARE_INTERFACE(QGraphicsItem, "com.trolltech.Qt.QGraphicsItem")
500 
501 inline void QGraphicsItem::setPos(qreal ax, qreal ay)
502 { setPos(QPointF(ax, ay)); }
503 inline void QGraphicsItem::ensureVisible(qreal ax, qreal ay, qreal w, qreal h, int xmargin, int ymargin)
504 { ensureVisible(QRectF(ax, ay, w, h), xmargin, ymargin); }
505 inline void QGraphicsItem::update(qreal ax, qreal ay, qreal width, qreal height)
506 { update(QRectF(ax, ay, width, height)); }
507 inline bool QGraphicsItem::isObscured(qreal ax, qreal ay, qreal w, qreal h) const
508 { return isObscured(QRectF(ax, ay, w, h)); }
509 inline QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay) const
510 { return mapToItem(item, QPointF(ax, ay)); }
512 { return mapToParent(QPointF(ax, ay)); }
514 { return mapToScene(QPointF(ax, ay)); }
515 inline QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay) const
516 { return mapFromItem(item, QPointF(ax, ay)); }
518 { return mapFromParent(QPointF(ax, ay)); }
520 { return mapFromScene(QPointF(ax, ay)); }
521 inline QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
522 { return mapToItem(item, QRectF(ax, ay, w, h)); }
524 { return mapToParent(QRectF(ax, ay, w, h)); }
526 { return mapToScene(QRectF(ax, ay, w, h)); }
527 inline QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
528 { return mapRectToItem(item, QRectF(ax, ay, w, h)); }
530 { return mapRectToParent(QRectF(ax, ay, w, h)); }
532 { return mapRectToScene(QRectF(ax, ay, w, h)); }
533 inline QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
534 { return mapFromItem(item, QRectF(ax, ay, w, h)); }
536 { return mapFromParent(QRectF(ax, ay, w, h)); }
538 { return mapFromScene(QRectF(ax, ay, w, h)); }
540 { return mapRectFromItem(item, QRectF(ax, ay, w, h)); }
542 { return mapRectFromParent(QRectF(ax, ay, w, h)); }
544 { return mapRectFromScene(QRectF(ax, ay, w, h)); }
545 
546 
548 {
549  Q_OBJECT
551  qreal opacity;
552  bool enabled;
553  bool visible;
561 #ifndef QT_NO_GRAPHICSEFFECT
563 #endif
564  Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty<QGraphicsObject> children READ childrenList DESIGNABLE false NOTIFY childrenChanged)
565  Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
566  Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
567  Q_CLASSINFO("DefaultProperty", "children")
569 public:
570  QGraphicsObject(QGraphicsItem *parent = 0);
571 
572  // ### Qt 5: Disambiguate
573 #ifdef Q_NO_USING_KEYWORD
574  const QObjectList &children() const { return QObject::children(); }
575 #else
576  using QObject::children;
577 #endif
578 
579 #ifndef QT_NO_GESTURES
580  void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
581  void ungrabGesture(Qt::GestureType type);
582 #endif
583 
584 protected Q_SLOTS:
585  void updateMicroFocus();
586 
587 Q_SIGNALS:
588  void parentChanged();
589  void opacityChanged();
590  void visibleChanged();
591  void enabledChanged();
592  void xChanged();
593  void yChanged();
594  void zChanged();
595  void rotationChanged();
596  void scaleChanged();
597  void childrenChanged();
598  void widthChanged();
599  void heightChanged();
600 
601 protected:
603 private:
604  friend class QGraphicsItem;
605  friend class QGraphicsItemPrivate;
606 };
607 
608 
611 {
612 public:
614 #ifndef Q_QDOC
615  // ### obsolete argument
616  , QGraphicsScene *scene = 0
617 #endif
618  );
620 
621  QPen pen() const;
622  void setPen(const QPen &pen);
623 
624  QBrush brush() const;
625  void setBrush(const QBrush &brush);
626 
627  bool isObscuredBy(const QGraphicsItem *item) const;
628  QPainterPath opaqueArea() const;
629 
630 protected:
632  QGraphicsItem *parent, QGraphicsScene *scene);
633 
634 private:
637 };
638 
641 {
642 public:
643  QGraphicsPathItem(QGraphicsItem *parent = 0
644 #ifndef Q_QDOC
645  // ### obsolete argument
646  , QGraphicsScene *scene = 0
647 #endif
648  );
649  QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0
650 #ifndef Q_QDOC
651  // ### obsolete argument
652  , QGraphicsScene *scene = 0
653 #endif
654  );
656 
657  QPainterPath path() const;
658  void setPath(const QPainterPath &path);
659 
660  QRectF boundingRect() const;
661  QPainterPath shape() const;
662  bool contains(const QPointF &point) const;
663 
664  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
665 
666  bool isObscuredBy(const QGraphicsItem *item) const;
667  QPainterPath opaqueArea() const;
668 
669  enum { Type = 2 };
670  int type() const;
671 
672 protected:
673  bool supportsExtension(Extension extension) const;
674  void setExtension(Extension extension, const QVariant &variant);
675  QVariant extension(const QVariant &variant) const;
676 
677 private:
680 };
681 
684 {
685 public:
686  QGraphicsRectItem(QGraphicsItem *parent = 0
687 #ifndef Q_QDOC
688  // ### obsolete argument
689  , QGraphicsScene *scene = 0
690 #endif
691  );
692  QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0
693 #ifndef Q_QDOC
694  // ### obsolete argument
695  , QGraphicsScene *scene = 0
696 #endif
697  );
698  QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0
699 #ifndef Q_QDOC
700  // ### obsolete argument
701  , QGraphicsScene *scene = 0
702 #endif
703  );
705 
706  QRectF rect() const;
707  void setRect(const QRectF &rect);
708  inline void setRect(qreal x, qreal y, qreal w, qreal h);
709 
710  QRectF boundingRect() const;
711  QPainterPath shape() const;
712  bool contains(const QPointF &point) const;
713 
714  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
715 
716  bool isObscuredBy(const QGraphicsItem *item) const;
717  QPainterPath opaqueArea() const;
718 
719  enum { Type = 3 };
720  int type() const;
721 
722 protected:
723  bool supportsExtension(Extension extension) const;
724  void setExtension(Extension extension, const QVariant &variant);
725  QVariant extension(const QVariant &variant) const;
726 
727 private:
730 };
731 
733 { setRect(QRectF(ax, ay, w, h)); }
734 
737 {
738 public:
740 #ifndef Q_QDOC
741  // ### obsolete argument
742  , QGraphicsScene *scene = 0
743 #endif
744  );
745  QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0
746 #ifndef Q_QDOC
747  // ### obsolete argument
748  , QGraphicsScene *scene = 0
749 #endif
750  );
751  QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0
752 #ifndef Q_QDOC
753  // ### obsolete argument
754  , QGraphicsScene *scene = 0
755 #endif
756  );
758 
759  QRectF rect() const;
760  void setRect(const QRectF &rect);
761  inline void setRect(qreal x, qreal y, qreal w, qreal h);
762 
763  int startAngle() const;
764  void setStartAngle(int angle);
765 
766  int spanAngle() const;
767  void setSpanAngle(int angle);
768 
769  QRectF boundingRect() const;
770  QPainterPath shape() const;
771  bool contains(const QPointF &point) const;
772 
773  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
774 
775  bool isObscuredBy(const QGraphicsItem *item) const;
776  QPainterPath opaqueArea() const;
777 
778  enum { Type = 4 };
779  int type() const;
780 
781 protected:
782  bool supportsExtension(Extension extension) const;
783  void setExtension(Extension extension, const QVariant &variant);
784  QVariant extension(const QVariant &variant) const;
785 
786 private:
789 };
790 
792 { setRect(QRectF(ax, ay, w, h)); }
793 
796 {
797 public:
799 #ifndef Q_QDOC
800  // ### obsolete argument
801  , QGraphicsScene *scene = 0
802 #endif
803  );
804  QGraphicsPolygonItem(const QPolygonF &polygon,
805  QGraphicsItem *parent = 0
806 #ifndef Q_QDOC
807  // ### obsolete argument
808  , QGraphicsScene *scene = 0
809 #endif
810  );
812 
813  QPolygonF polygon() const;
814  void setPolygon(const QPolygonF &polygon);
815 
816  Qt::FillRule fillRule() const;
817  void setFillRule(Qt::FillRule rule);
818 
819  QRectF boundingRect() const;
820  QPainterPath shape() const;
821  bool contains(const QPointF &point) const;
822 
823  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
824 
825  bool isObscuredBy(const QGraphicsItem *item) const;
826  QPainterPath opaqueArea() const;
827 
828  enum { Type = 5 };
829  int type() const;
830 
831 protected:
832  bool supportsExtension(Extension extension) const;
833  void setExtension(Extension extension, const QVariant &variant);
834  QVariant extension(const QVariant &variant) const;
835 
836 private:
839 };
840 
843 {
844 public:
845  QGraphicsLineItem(QGraphicsItem *parent = 0
846 #ifndef Q_QDOC
847  // ### obsolete argument
848  , QGraphicsScene *scene = 0
849 #endif
850  );
851  QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0
852 #ifndef Q_QDOC
853  // ### obsolete argument
854  , QGraphicsScene *scene = 0
855 #endif
856  );
857  QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0
858 #ifndef Q_QDOC
859  // ### obsolete argument
860  , QGraphicsScene *scene = 0
861 #endif
862  );
864 
865  QPen pen() const;
866  void setPen(const QPen &pen);
867 
868  QLineF line() const;
869  void setLine(const QLineF &line);
870  inline void setLine(qreal x1, qreal y1, qreal x2, qreal y2)
871  { setLine(QLineF(x1, y1, x2, y2)); }
872 
873  QRectF boundingRect() const;
874  QPainterPath shape() const;
875  bool contains(const QPointF &point) const;
876 
877  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
878 
879  bool isObscuredBy(const QGraphicsItem *item) const;
880  QPainterPath opaqueArea() const;
881 
882  enum { Type = 6 };
883  int type() const;
884 
885 protected:
886  bool supportsExtension(Extension extension) const;
887  void setExtension(Extension extension, const QVariant &variant);
888  QVariant extension(const QVariant &variant) const;
889 
890 private:
893 };
894 
897 {
898 public:
899  enum ShapeMode {
902  HeuristicMaskShape
903  };
904 
906 #ifndef Q_QDOC
907  // ### obsolete argument
908  , QGraphicsScene *scene = 0
909 #endif
910  );
911  QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0
912 #ifndef Q_QDOC
913  // ### obsolete argument
914  , QGraphicsScene *scene = 0
915 #endif
916  );
918 
919  QPixmap pixmap() const;
920  void setPixmap(const QPixmap &pixmap);
921 
922  Qt::TransformationMode transformationMode() const;
923  void setTransformationMode(Qt::TransformationMode mode);
924 
925  QPointF offset() const;
926  void setOffset(const QPointF &offset);
927  inline void setOffset(qreal x, qreal y);
928 
929  QRectF boundingRect() const;
930  QPainterPath shape() const;
931  bool contains(const QPointF &point) const;
932 
933  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
934 
935  bool isObscuredBy(const QGraphicsItem *item) const;
936  QPainterPath opaqueArea() const;
937 
938  enum { Type = 7 };
939  int type() const;
940 
941  ShapeMode shapeMode() const;
942  void setShapeMode(ShapeMode mode);
943 
944 protected:
945  bool supportsExtension(Extension extension) const;
946  void setExtension(Extension extension, const QVariant &variant);
947  QVariant extension(const QVariant &variant) const;
948 
949 private:
952 };
953 
955 { setOffset(QPointF(ax, ay)); }
956 
958 class QTextDocument;
959 class QTextCursor;
961 {
962  Q_OBJECT
963  QDOC_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
964  QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor)
965 
966 public:
967  QGraphicsTextItem(QGraphicsItem *parent = 0
968 #ifndef Q_QDOC
969  // ### obsolete argument
970  , QGraphicsScene *scene = 0
971 #endif
972  );
973  QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0
974 #ifndef Q_QDOC
975  // ### obsolete argument
976  , QGraphicsScene *scene = 0
977 #endif
978  );
980 
981  QString toHtml() const;
982  void setHtml(const QString &html);
983 
984  QString toPlainText() const;
985  void setPlainText(const QString &text);
986 
987  QFont font() const;
988  void setFont(const QFont &font);
989 
990  void setDefaultTextColor(const QColor &c);
991  QColor defaultTextColor() const;
992 
993  QRectF boundingRect() const;
994  QPainterPath shape() const;
995  bool contains(const QPointF &point) const;
996 
997  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
998 
999  bool isObscuredBy(const QGraphicsItem *item) const;
1000  QPainterPath opaqueArea() const;
1001 
1002  enum { Type = 8 };
1003  int type() const;
1004 
1005  void setTextWidth(qreal width);
1006  qreal textWidth() const;
1007 
1008  void adjustSize();
1009 
1010  void setDocument(QTextDocument *document);
1011  QTextDocument *document() const;
1012 
1013  void setTextInteractionFlags(Qt::TextInteractionFlags flags);
1014  Qt::TextInteractionFlags textInteractionFlags() const;
1015 
1016  void setTabChangesFocus(bool b);
1017  bool tabChangesFocus() const;
1018 
1019  void setOpenExternalLinks(bool open);
1020  bool openExternalLinks() const;
1021 
1022  void setTextCursor(const QTextCursor &cursor);
1023  QTextCursor textCursor() const;
1024 
1025 Q_SIGNALS:
1026  void linkActivated(const QString &);
1027  void linkHovered(const QString &);
1028 
1029 protected:
1030  bool sceneEvent(QEvent *event);
1036  void keyPressEvent(QKeyEvent *event);
1037  void keyReleaseEvent(QKeyEvent *event);
1038  void focusInEvent(QFocusEvent *event);
1039  void focusOutEvent(QFocusEvent *event);
1044  void inputMethodEvent(QInputMethodEvent *event);
1048 
1050 
1051  bool supportsExtension(Extension extension) const;
1052  void setExtension(Extension extension, const QVariant &variant);
1053  QVariant extension(const QVariant &variant) const;
1054 
1055 private:
1057  Q_PRIVATE_SLOT(dd, void _q_updateBoundingRect(const QSizeF &))
1058  Q_PRIVATE_SLOT(dd, void _q_update(QRectF))
1059  Q_PRIVATE_SLOT(dd, void _q_ensureVisible(QRectF))
1062 };
1063 
1066 {
1067 public:
1069 #ifndef Q_QDOC
1070  // ### obsolete argument
1071  , QGraphicsScene *scene = 0
1072 #endif
1073  );
1074  QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0
1075 #ifndef Q_QDOC
1076  // ### obsolete argument
1077  , QGraphicsScene *scene = 0
1078 #endif
1079  );
1081 
1082  void setText(const QString &text);
1083  QString text() const;
1084 
1085  void setFont(const QFont &font);
1086  QFont font() const;
1087 
1088  QRectF boundingRect() const;
1089  QPainterPath shape() const;
1090  bool contains(const QPointF &point) const;
1091 
1092  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
1093 
1094  bool isObscuredBy(const QGraphicsItem *item) const;
1095  QPainterPath opaqueArea() const;
1096 
1097  enum { Type = 9 };
1098  int type() const;
1099 
1100 protected:
1101  bool supportsExtension(Extension extension) const;
1102  void setExtension(Extension extension, const QVariant &variant);
1103  QVariant extension(const QVariant &variant) const;
1104 
1105 private:
1108 };
1109 
1112 {
1113 public:
1114  QGraphicsItemGroup(QGraphicsItem *parent = 0
1115 #ifndef Q_QDOC
1116  // ### obsolete argument
1117  , QGraphicsScene *scene = 0
1118 #endif
1119  );
1120  ~QGraphicsItemGroup();
1121 
1122  void addToGroup(QGraphicsItem *item);
1123  void removeFromGroup(QGraphicsItem *item);
1124 
1125  QRectF boundingRect() const;
1126  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
1127 
1128  bool isObscuredBy(const QGraphicsItem *item) const;
1129  QPainterPath opaqueArea() const;
1130 
1131  enum { Type = 10 };
1132  int type() const;
1133 
1134 private:
1137 };
1138 
1139 template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item)
1140 {
1141  return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type)
1142  || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0;
1143 }
1144 
1145 template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item)
1146 {
1147  return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type)
1148  || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0;
1149 }
1150 
1151 #ifndef QT_NO_DEBUG_STREAM
1156 Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags);
1157 #endif
1158 
1160 
1163 
1165 
1166 #endif // QT_NO_GRAPHICSVIEW
1167 
1169 
1171 
1172 #endif // QGRAPHICSITEM_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void updateMicroFocus()
Updates the item&#39;s micro focus.
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
The QKeyEvent class describes a key event.
Definition: qevent.h:224
virtual bool sceneEvent(QEvent *event)
This virtual function receives events to this item.
int type
Definition: qmetatype.cpp:239
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
Definition: qobjectdefs.h:78
double qreal
Definition: qglobal.h:1193
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
The type value returned by the virtual type() function in standard graphics item classes in Qt...
#define QDOC_PROPERTY(text)
Definition: qglobal.h:2503
EventRef event
QPointer< QWidget > widget
#define QT_MODULE(x)
Definition: qglobal.h:2783
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define Q_PRIVATE_PROPERTY(d, define Q_REVISION(v)
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
qreal y
the y position of the item
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
QPointF mapFromItem(const QGraphicsItem *item, const QPointF &point) const
Maps the point point, which is in item&#39;s coordinate system, to this item&#39;s coordinate system...
virtual void inputMethodEvent(QInputMethodEvent *event)
This event handler, for event event, can be reimplemented to receive input method events for this ite...
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QGraphicsEffect * effect
the effect attached to this item
FillRule
Definition: qnamespace.h:1485
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QGraphicsEllipseItem class provides an ellipse item that you can add to a QGraphicsScene.
The QGraphicsSceneBspTreeIndex class provides an implementation of a BSP indexing algorithm for disco...
virtual bool isObscuredBy(const QGraphicsItem *item) const
Returns true if this item&#39;s bounding rect is completely obscured by the opaque shape of item...
qreal rotation
This property holds the rotation of the item in degrees.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
GraphicsItemFlag
This enum describes different flags that you can set on an item to toggle different features in the i...
Definition: qgraphicsitem.h:92
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
ItemSelectionMode
Definition: qnamespace.h:1503
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
#define Q_SLOTS
Definition: qobjectdefs.h:71
QRectF mapRectToScene(const QRectF &rect) const
Maps the rectangle rect, which is in this item&#39;s coordinate system, to the scene coordinate system...
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
This method is only relevant for input items.
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drag enter events for this item...
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display form...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
qreal z
the z value of the item
The QGraphicsPolygonItem class provides a polygon item that you can add to a QGraphicsScene.
#define Q_SIGNALS
Definition: qobjectdefs.h:72
virtual void keyPressEvent(QKeyEvent *event)
This event handler, for event event, can be reimplemented to receive key press events for this item...
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define Q_DECLARE_INTERFACE(IFace, IId)
Definition: qobject.h:397
virtual QPainterPath shape() const
Returns the shape of this item as a QPainterPath in local coordinates.
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
virtual void focusInEvent(QFocusEvent *event)
This event handler, for event event, can be reimplemented to receive focus in events for this item...
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover leave events for this item...
static const QRectF boundingRect(const QPointF *points, int pointCount)
bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem *item2)
Returns true if item1 is on top of item2.
NSWindow * window
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem *item)
QPainterPath opaqueArea() const
Reimplemented Function
QRectF mapRectFromScene(const QRectF &rect) const
Maps the rectangle rect, which is in scene coordinates, to this item&#39;s coordinate system...
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
Definition: qmime_win.cpp:141
friend class QGraphicsObject
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover move events for this item...
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
virtual int type() const
Returns the type of an item as an int.
TransformationMode
Definition: qnamespace.h:1510
ShapeMode
This enum describes how QGraphicsPixmapItem calculates its shape and opaque area. ...
static const char * data(const QByteArray &arr)
void ensureVisible(const QRectF &rect=QRectF(), int xmargin=50, int ymargin=50)
If this item is part of a scene that is viewed by a QGraphicsView, this convenience function will att...
QRectF mapRectToParent(const QRectF &rect) const
Maps the rectangle rect, which is in this item&#39;s coordinate system, to its parent&#39;s coordinate system...
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QGraphicsSceneEvent class provides a base class for all graphics view related events...
The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for disc...
void moveBy(qreal dx, qreal dy)
Moves the item by dx points horizontally, and dy point vertically.
virtual bool supportsExtension(Extension extension) const
Note: This is provided as a hook to avoid future problems related to adding virtual functions...
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drag leave events for this item...
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
This event handler can be reimplemented in a subclass to process context menu events.
virtual QPainterPath opaqueArea() const
This virtual function returns a shape representing the area where this item is opaque.
GestureType
Definition: qnamespace.h:1759
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
void setTransformOriginPoint(qreal ax, qreal ay)
Sets the origin point for the transformation in item coordinates.
static QWidget * parentWidget(const QWidget *w)
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item&#39;s scene&#39;s coordinate system, to this item&#39;s coordinate sy...
InputMethodQuery
Definition: qnamespace.h:1541
QRectF mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const
Maps the rectangle rect, which is in this item&#39;s coordinate system, to item&#39;s coordinate system...
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QPointF pos
the position of the item
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drag move events for this item...
The QGraphicsSimpleTextItem class provides a simple text path item that you can add to a QGraphicsSce...
The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene.
QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const
Maps the point point, which is in this item&#39;s coordinate system, to item&#39;s coordinate system...
qreal angle(const QPointF &p1, const QPointF &p2)
CacheMode
This enum describes QGraphicsItem&#39;s cache modes.
qreal y() const
This convenience function is equivalent to calling pos().
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QAbstractGraphicsShapeItem class provides a common base for all path items.
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover enter events for this item...
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
FocusReason
Definition: qnamespace.h:1521
virtual QVariant extension(const QVariant &variant) const
Note: This is provided as a hook to avoid future problems related to adding virtual functions...
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
virtual void dropEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drop events for this item...
void setLine(qreal x1, qreal y1, qreal x2, qreal y2)
Sets the item&#39;s line to be the line between (x1, y1) and (x2, y2).
#define Q_INTERFACES(x)
This macro tells Qt which interfaces the class implements.
Definition: qobjectdefs.h:79
qreal x() const
This convenience function is equivalent to calling pos().
int key
void hide()
Hides the item.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
void setRect(const QRectF &rect)
Sets the item&#39;s rectangle to be the given rectangle.
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
bool visible
whether the item is visible or not
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QGraphicsItemGroup class provides a container that treats a group of items as a single item...
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
T qgraphicsitem_cast(QGraphicsItem *item)
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)=0
This function, which is usually called by QGraphicsView, paints the contents of an item in local coor...
QRectF mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const
Maps the rectangle rect, which is in item&#39;s coordinate system, to this item&#39;s coordinate system...
qreal scale
This property holds the scale of the item.
bool enabled
whether the item is enabled or not
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
friend class QGraphicsItemGroup
bool isObscuredBy(const QGraphicsItem *item) const
Reimplemented Function
virtual void setExtension(Extension extension, const QVariant &variant)
Note: This is provided as a hook to avoid future problems related to adding virtual functions...
const char * variant
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
Extension
Note: This is provided as a hook to avoid future problems related to adding virtual functions...
qreal x
the x position of the item
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler, for event event, can be reimplemented to receive key release events for this item...
QPointF mapFromParent(const QPointF &point) const
Maps the point point, which is in this item&#39;s parent&#39;s coordinate system, to this item&#39;s coordinate s...
#define class
PanelModality
This enum specifies the behavior of a modal panel.
The QGraphicsObject class provides a base class for all graphics items that require signals...
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.
QPointF mapToScene(const QPointF &point) const
Maps the point point, which is in this item&#39;s coordinate system, to the scene&#39;s coordinate system...
void setOffset(const QPointF &offset)
Sets the pixmap item&#39;s offset to offset.
virtual void focusOutEvent(QFocusEvent *event)
This event handler, for event event, can be reimplemented to receive focus out events for this item...
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
Definition: qstyleoption.h:867
void setRect(const QRectF &rect)
Sets the item&#39;s ellipse geometry to rect.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...
QList< QGraphicsItem * > children() const
Use childItems() instead.
The QGraphicsTransform class is an abstract base class for building advanced transformations on QGrap...
#define enabled
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
bool isObscured() const
Returns true if this item&#39;s bounding rect is completely obscured by the opaque shape of any of collid...
int open(const char *, int,...)
#define text
Definition: qobjectdefs.h:80
QPointF mapToParent(const QPointF &point) const
Maps the point point, which is in this item&#39;s coordinate system, to its parent&#39;s coordinate system...
The QGraphicsEffect class is the base class for all graphics effects.
QRectF mapRectFromParent(const QRectF &rect) const
Maps the rectangle rect, which is in this item&#39;s parent&#39;s coordinate system, to this item&#39;s coordinat...
bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
The QGraphicsPathItem class provides a path item that you can add to a QGraphicsScene.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
void show()
Shows the item.
QGraphicsObject *qreal opacity
the opacity of the item
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
QPointF transformOriginPoint
the transformation origin
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework...