42 #ifndef QGRAPHICSITEM_H 43 #define QGRAPHICSITEM_H 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> 53 class tst_QGraphicsItem;
61 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW 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,
109 ItemSendsScenePositionChanges = 0x10000,
110 ItemStopsClickFocusPropagation = 0x20000,
111 ItemStopsFocusHandling = 0x40000
150 ItemTransformOriginPointHasChanged
156 DeviceCoordinateCache
186 bool isWidget()
const;
187 bool isWindow()
const;
188 bool isPanel()
const;
196 GraphicsItemFlags flags()
const;
198 void setFlags(GraphicsItemFlags flags);
205 bool isBlockedByModalPanel(
QGraphicsItem **blockingPanel = 0)
const;
207 #ifndef QT_NO_TOOLTIP 209 void setToolTip(
const QString &toolTip);
214 void setCursor(
const QCursor &cursor);
215 bool hasCursor()
const;
219 bool isVisible()
const;
221 void setVisible(
bool visible);
222 inline void hide() { setVisible(
false); }
223 inline void show() { setVisible(
true); }
225 bool isEnabled()
const;
228 bool isSelected()
const;
229 void setSelected(
bool selected);
231 bool acceptDrops()
const;
232 void setAcceptDrops(
bool on);
234 qreal opacity()
const;
235 qreal effectiveOpacity()
const;
236 void setOpacity(
qreal opacity);
238 #ifndef QT_NO_GRAPHICSEFFECT 242 #endif //QT_NO_GRAPHICSEFFECT 244 Qt::MouseButtons acceptedMouseButtons()
const;
245 void setAcceptedMouseButtons(Qt::MouseButtons
buttons);
247 bool acceptsHoverEvents()
const;
248 void setAcceptsHoverEvents(
bool enabled);
249 bool acceptHoverEvents()
const;
250 void setAcceptHoverEvents(
bool enabled);
251 bool acceptTouchEvents()
const;
252 void setAcceptTouchEvents(
bool enabled);
254 bool filtersChildEvents()
const;
255 void setFiltersChildEvents(
bool enabled);
257 bool handlesChildEvents()
const;
258 void setHandlesChildEvents(
bool enabled);
260 bool isActive()
const;
261 void setActive(
bool active);
263 bool hasFocus()
const;
276 void ungrabKeyboard();
285 void setPos(
const QPointF &pos);
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);
295 void setMatrix(
const QMatrix &matrix,
bool combine =
false);
301 void setTransform(
const QTransform &matrix,
bool combine =
false);
302 void resetTransform();
309 void setRotation(
qreal angle);
310 qreal rotation()
const;
312 void setScale(
qreal scale);
318 QPointF transformOriginPoint()
const;
319 void setTransformOriginPoint(
const QPointF &origin);
321 { setTransformOriginPoint(
QPointF(ax,ay)); }
323 virtual void advance(
int phase);
326 qreal zValue()
const;
327 void setZValue(
qreal z);
332 QRectF childrenBoundingRect()
const;
333 QRectF sceneBoundingRect()
const;
335 bool isClipped()
const;
337 virtual bool contains(
const QPointF &point)
const;
341 bool isObscured()
const;
342 bool isObscured(
const QRectF &rect)
const;
348 qreal boundingRegionGranularity()
const;
349 void setBoundingRegionGranularity(
qreal granularity);
410 bool isUnderMouse()
const;
416 Qt::InputMethodHints inputMethodHints()
const;
417 void setInputMethodHints(Qt::InputMethodHints hints);
423 virtual int type()
const;
429 void updateMicroFocus();
455 UserExtension = 0x80000000
457 virtual bool supportsExtension(
Extension extension)
const;
467 void removeFromIndex();
468 void prepareGeometryChange();
490 #ifndef QT_NO_GESTURES 493 friend class ::tst_QGraphicsItem;
504 { ensureVisible(
QRectF(ax, ay, w, h), xmargin, ymargin); }
506 { update(
QRectF(ax, ay, width, height)); }
508 {
return isObscured(
QRectF(ax, ay, w, h)); }
510 {
return mapToItem(item,
QPointF(ax, ay)); }
512 {
return mapToParent(
QPointF(ax, ay)); }
514 {
return mapToScene(
QPointF(ax, ay)); }
516 {
return mapFromItem(item,
QPointF(ax, ay)); }
518 {
return mapFromParent(
QPointF(ax, ay)); }
520 {
return mapFromScene(
QPointF(ax, ay)); }
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)); }
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)); }
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)); }
561 #ifndef QT_NO_GRAPHICSEFFECT 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)
573 #ifdef Q_NO_USING_KEYWORD 579 #ifndef QT_NO_GESTURES 588 void parentChanged();
589 void opacityChanged();
590 void visibleChanged();
591 void enabledChanged();
595 void rotationChanged();
597 void childrenChanged();
599 void heightChanged();
622 void setPen(
const QPen &pen);
625 void setBrush(
const QBrush &brush);
707 void setRect(
const QRectF &rect);
733 { setRect(
QRectF(ax, ay, w, h)); }
760 void setRect(
const QRectF &rect);
763 int startAngle()
const;
764 void setStartAngle(
int angle);
766 int spanAngle()
const;
767 void setSpanAngle(
int angle);
792 { setRect(
QRectF(ax, ay, w, h)); }
814 void setPolygon(
const QPolygonF &polygon);
866 void setPen(
const QPen &pen);
869 void setLine(
const QLineF &line);
871 { setLine(
QLineF(x1, y1, x2, y2)); }
920 void setPixmap(
const QPixmap &pixmap);
926 void setOffset(
const QPointF &offset);
955 { setOffset(
QPointF(ax, ay)); }
963 QDOC_PROPERTY(
bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
982 void setHtml(
const QString &html);
985 void setPlainText(
const QString &text);
988 void setFont(
const QFont &font);
990 void setDefaultTextColor(
const QColor &
c);
991 QColor defaultTextColor()
const;
1005 void setTextWidth(
qreal width);
1006 qreal textWidth()
const;
1013 void setTextInteractionFlags(Qt::TextInteractionFlags flags);
1014 Qt::TextInteractionFlags textInteractionFlags()
const;
1016 void setTabChangesFocus(
bool b);
1017 bool tabChangesFocus()
const;
1019 void setOpenExternalLinks(
bool open);
1020 bool openExternalLinks()
const;
1026 void linkActivated(
const QString &);
1027 void linkHovered(
const QString &);
1082 void setText(
const QString &text);
1085 void setFont(
const QFont &font);
1142 || (item && int(static_cast<T>(0)->
Type) == item->
type()) ? static_cast<T>(item) : 0;
1148 || (item && int(static_cast<T>(0)->
Type) == item->
type()) ? static_cast<T>(item) : 0;
1151 #ifndef QT_NO_DEBUG_STREAM 1166 #endif // QT_NO_GRAPHICSVIEW 1172 #endif // QGRAPHICSITEM_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.
void updateMicroFocus()
Updates the item's micro focus.
The QDebug class provides an output stream for debugging information.
The QColor class provides colors based on RGB, HSV or CMYK values.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
The QKeyEvent class describes a key event.
virtual bool sceneEvent(QEvent *event)
This virtual function receives events to this item.
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
The QCursor class provides a mouse cursor with an arbitrary shape.
#define QT_END_NAMESPACE
This macro expands to.
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)
QPointer< QWidget > widget
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define Q_PRIVATE_PROPERTY(d, define Q_REVISION(v)
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
qreal y
the y position of the item
The QMatrix class specifies 2D transformations of a coordinate system.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
QPointF mapFromItem(const QGraphicsItem *item, const QPointF &point) const
Maps the point point, which is in item's coordinate system, to this item'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.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QGraphicsEffect * effect
the effect attached to this item
static Qt::MouseButtons buttons
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'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.
#define Q_PRIVATE_SLOT(d, signature)
GraphicsItemFlag
This enum describes different flags that you can set on an item to toggle different features in the i...
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
QRectF mapRectToScene(const QRectF &rect) const
Maps the rectangle rect, which is in this item'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.
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.
qreal z
the z value of the item
The QGraphicsPolygonItem class provides a polygon item that you can add to a QGraphicsScene.
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.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
#define Q_DECLARE_INTERFACE(IFace, IId)
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.
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.
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.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
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's coordinate system...
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
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.
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
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.
virtual int type() const
Returns the type of an item as an int.
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's coordinate system, to its parent's coordinate system...
The QRegion class specifies a clip region for a painter.
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.
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's scene's coordinate system, to this item's coordinate sy...
QRectF mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const
Maps the rectangle rect, which is in this item's coordinate system, to item's coordinate system...
The QBrush class defines the fill pattern of shapes drawn by QPainter.
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's coordinate system, to item's coordinate system...
qreal angle(const QPointF &p1, const QPointF &p2)
CacheMode
This enum describes QGraphicsItem's cache modes.
qreal y() const
This convenience function is equivalent to calling pos().
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...
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.
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'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.
qreal x() const
This convenience function is equivalent to calling pos().
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's rectangle to be the given rectangle.
const QObjectList & children() const
Returns a list of child objects.
bool visible
whether the item is visible or not
qreal y() const
Returns the y-coordinate of this point.
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...
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.
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's coordinate system, to this item'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.
#define Q_DECLARE_PRIVATE(Class)
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...
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's parent's coordinate system, to this item's coordinate s...
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.
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's coordinate system, to the scene's coordinate system...
void setOffset(const QPointF &offset)
Sets the pixmap item'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...
void setRect(const QRectF &rect)
Sets the item'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 QFocusEvent class contains event parameters for widget focus events.
bool isObscured() const
Returns true if this item's bounding rect is completely obscured by the opaque shape of any of collid...
int open(const char *, int,...)
QPointF mapToParent(const QPointF &point) const
Maps the point point, which is in this item's coordinate system, to its parent'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's parent's coordinate system, to this item's coordinat...
bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)
The QList class is a template class that provides lists.
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
QPointF transformOriginPoint
the transformation origin