Qt 4.8
Public Types | Public Functions | Protected Functions | List of all members
QGraphicsPixmapItem Class Reference

The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene. More...

#include <qgraphicsitem.h>

Inheritance diagram for QGraphicsPixmapItem:
QGraphicsItem

Public Types

enum  { Type = 7 }
 
enum  ShapeMode { MaskShape, BoundingRectShape, HeuristicMaskShape }
 This enum describes how QGraphicsPixmapItem calculates its shape and opaque area. More...
 
- Public Types inherited from QGraphicsItem
enum  { Type = 1, UserType = 65536 }
 
enum  CacheMode { NoCache, ItemCoordinateCache, DeviceCoordinateCache }
 This enum describes QGraphicsItem's cache modes. More...
 
enum  GraphicsItemChange {
  ItemPositionChange, ItemMatrixChange, ItemVisibleChange, ItemEnabledChange,
  ItemSelectedChange, ItemParentChange, ItemChildAddedChange, ItemChildRemovedChange,
  ItemTransformChange, ItemPositionHasChanged, ItemTransformHasChanged, ItemSceneChange,
  ItemVisibleHasChanged, ItemEnabledHasChanged, ItemSelectedHasChanged, ItemParentHasChanged,
  ItemSceneHasChanged, ItemCursorChange, ItemCursorHasChanged, ItemToolTipChange,
  ItemToolTipHasChanged, ItemFlagsChange, ItemFlagsHaveChanged, ItemZValueChange,
  ItemZValueHasChanged, ItemOpacityChange, ItemOpacityHasChanged, ItemScenePositionHasChanged,
  ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged,
  ItemTransformOriginPointChange, ItemTransformOriginPointHasChanged
}
 This enum describes the state changes that are notified by QGraphicsItem::itemChange(). More...
 
enum  GraphicsItemFlag {
  ItemIsMovable = 0x1, ItemIsSelectable = 0x2, ItemIsFocusable = 0x4, ItemClipsToShape = 0x8,
  ItemClipsChildrenToShape = 0x10, ItemIgnoresTransformations = 0x20, ItemIgnoresParentOpacity = 0x40, ItemDoesntPropagateOpacityToChildren = 0x80,
  ItemStacksBehindParent = 0x100, ItemUsesExtendedStyleOption = 0x200, ItemHasNoContents = 0x400, ItemSendsGeometryChanges = 0x800,
  ItemAcceptsInputMethod = 0x1000, ItemNegativeZStacksBehindParent = 0x2000, ItemIsPanel = 0x4000, ItemIsFocusScope = 0x8000,
  ItemSendsScenePositionChanges = 0x10000, ItemStopsClickFocusPropagation = 0x20000, ItemStopsFocusHandling = 0x40000
}
 This enum describes different flags that you can set on an item to toggle different features in the item's behavior. More...
 
enum  PanelModality { NonModal, PanelModal, SceneModal }
 This enum specifies the behavior of a modal panel. More...
 

Public Functions

QRectF boundingRect () const
 Reimplemented Function More...
 
bool contains (const QPointF &point) const
 Reimplemented Function More...
 
bool isObscuredBy (const QGraphicsItem *item) const
 Reimplemented Function More...
 
QPointF offset () const
 Returns the pixmap item's offset, which defines the point of the top-left corner of the pixmap, in local coordinates. More...
 
QPainterPath opaqueArea () const
 Reimplemented Function More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Reimplemented Function More...
 
QPixmap pixmap () const
 Returns the item's pixmap, or an invalid QPixmap if no pixmap has been set. More...
 
 QGraphicsPixmapItem (QGraphicsItem *parent=0)
 Constructs a QGraphicsPixmapItem. More...
 
 QGraphicsPixmapItem (const QPixmap &pixmap, QGraphicsItem *parent=0)
 Constructs a QGraphicsPixmapItem, using pixmap as the default pixmap. More...
 
void setOffset (const QPointF &offset)
 Sets the pixmap item's offset to offset. More...
 
void setOffset (qreal x, qreal y)
 This convenience function is equivalent to calling setOffset(QPointF(x, y)). More...
 
void setPixmap (const QPixmap &pixmap)
 Sets the item's pixmap to pixmap. More...
 
void setShapeMode (ShapeMode mode)
 Sets the item's shape mode to mode. More...
 
void setTransformationMode (Qt::TransformationMode mode)
 Sets the pixmap item's transformation mode to mode, and toggles an update of the item. More...
 
QPainterPath shape () const
 Reimplemented Function More...
 
ShapeMode shapeMode () const
 Returns the item's shape mode. More...
 
Qt::TransformationMode transformationMode () const
 Returns the transformation mode of the pixmap. More...
 
int type () const
 Reimplemented Function More...
 
 ~QGraphicsPixmapItem ()
 Destroys the QGraphicsPixmapItem. More...
 
- Public Functions inherited from QGraphicsItem
bool acceptDrops () const
 Returns true if this item can accept drag and drop events; otherwise, returns false. More...
 
Qt::MouseButtons acceptedMouseButtons () const
 Returns the mouse buttons that this item accepts mouse events for. More...
 
bool acceptHoverEvents () const
 Returns true if an item accepts hover events (QGraphicsSceneHoverEvent); otherwise, returns false. More...
 
bool acceptsHoverEvents () const
 Call acceptHoverEvents() instead. More...
 
bool acceptTouchEvents () const
 Returns true if an item accepts touch events; otherwise, returns false. More...
 
virtual void advance (int phase)
 This virtual function is called twice for all items by the QGraphicsScene::advance() slot. More...
 
QRegion boundingRegion (const QTransform &itemToDeviceTransform) const
 Returns the bounding region for this item. More...
 
qreal boundingRegionGranularity () const
 Returns the item's bounding region granularity; a value between and including 0 and 1. More...
 
CacheMode cacheMode () const
 Returns the cache mode for this item. More...
 
QList< QGraphicsItem * > childItems () const
 Returns a list of this item's children. More...
 
QList< QGraphicsItem * > children () const
 Use childItems() instead. More...
 
QRectF childrenBoundingRect () const
 Returns the bounding rect of this item's descendants (i.e., its children, their children, etc.) in local coordinates. More...
 
void clearFocus ()
 Takes keyboard input focus from the item. More...
 
QPainterPath clipPath () const
 Returns this item's clip path, or an empty QPainterPath if this item is not clipped. More...
 
virtual bool collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns true if this item collides with other; otherwise returns false. More...
 
virtual bool collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns true if this item collides with path. More...
 
QList< QGraphicsItem * > collidingItems (Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns a list of all items that collide with this item. More...
 
QGraphicsItemcommonAncestorItem (const QGraphicsItem *other) const
 Returns the closest common ancestor item of this item and other, or 0 if either other is 0, or there is no common ancestor. More...
 
QCursor cursor () const
 Returns the current cursor shape for the item. More...
 
QVariant data (int key) const
 Returns this item's custom data for the key key as a QVariant. More...
 
QTransform deviceTransform (const QTransform &viewportTransform) const
 Returns this item's device transformation matrix, using viewportTransform to map from scene to device coordinates. More...
 
qreal effectiveOpacity () const
 Returns this item's effective opacity, which is between 0. More...
 
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 attempt to scroll the view to ensure that rect is visible inside the view's viewport. More...
 
void ensureVisible (qreal x, qreal y, qreal w, qreal h, int xmargin=50, int ymargin=50)
 This convenience function is equivalent to calling ensureVisible(QRectF(x, y, w, h), xmargin, ymargin): More...
 
bool filtersChildEvents () const
 Returns true if this item filters child events (i. More...
 
GraphicsItemFlags flags () const
 Returns this item's flags. More...
 
QGraphicsItemfocusItem () const
 If this item, a child or descendant of this item currently has input focus, this function will return a pointer to that item. More...
 
QGraphicsItemfocusProxy () const
 Returns this item's focus proxy, or 0 if this item has no focus proxy. More...
 
QGraphicsItemfocusScopeItem () const
 Returns this item's focus scope item. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
QGraphicsEffectgraphicsEffect () const
 Returns a pointer to this item's effect if it has one; otherwise 0. More...
 
QGraphicsItemGroupgroup () const
 Returns a pointer to this item's item group, or 0 if this item is not member of a group. More...
 
bool handlesChildEvents () const
 Returns true if this item handles child events (i. More...
 
bool hasCursor () const
 Returns true if this item has a cursor set; otherwise, false is returned. More...
 
bool hasFocus () const
 Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise, returns false. More...
 
void hide ()
 Hides the item. More...
 
Qt::InputMethodHints inputMethodHints () const
 Returns the current input method hints of this item. More...
 
void installSceneEventFilter (QGraphicsItem *filterItem)
 Installs an event filter for this item on filterItem, causing all events for this item to first pass through filterItem's sceneEventFilter() function. More...
 
bool isActive () const
 Returns true if this item is active; otherwise returns false. More...
 
bool isAncestorOf (const QGraphicsItem *child) const
 Returns true if this item is an ancestor of child (i.e., if this item is child's parent, or one of child's parent's ancestors). More...
 
bool isBlockedByModalPanel (QGraphicsItem **blockingPanel=0) const
 Returns true if this item is blocked by a modal panel, false otherwise. More...
 
bool isClipped () const
 Returns true if this item is clipped. More...
 
bool isEnabled () const
 Returns true if the item is enabled; otherwise, false is returned. More...
 
bool isObscured () const
 Returns true if this item's bounding rect is completely obscured by the opaque shape of any of colliding items above it (i.e., with a higher Z value than this item). More...
 
bool isObscured (const QRectF &rect) const
 Returns true if rect is completely obscured by the opaque shape of any of colliding items above it (i. More...
 
bool isObscured (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling isObscured(QRectF(x, y, w, h)). More...
 
bool isPanel () const
 Returns true if the item is a panel; otherwise returns false. More...
 
bool isSelected () const
 Returns true if this item is selected; otherwise, false is returned. More...
 
bool isUnderMouse () const
 Returns true if this item is currently under the mouse cursor in one of the views; otherwise, false is returned. More...
 
bool isVisible () const
 Returns true if the item is visible; otherwise, false is returned. More...
 
bool isVisibleTo (const QGraphicsItem *parent) const
 Returns true if the item is visible to parent; otherwise, false is returned. More...
 
bool isWidget () const
 Returns true if this item is a widget (i. More...
 
bool isWindow () const
 Returns true if the item is a QGraphicsWidget window, otherwise returns false. More...
 
QTransform itemTransform (const QGraphicsItem *other, bool *ok=0) const
 Returns a QTransform that maps coordinates from this item to other. More...
 
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, and returns the mapped coordinate. More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in item's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 Maps the polygon polygon, which is in item's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromItem (const QGraphicsItem *item, const QPainterPath &path) const
 Maps the path path, which is in item's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromItem (const QGraphicsItem *item, qreal x, qreal y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This convenience function is equivalent to calling mapFromItem(item, QPointF(x, y)). More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
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 system, and returns the mapped coordinate. More...
 
QPolygonF mapFromParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromParent (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromParent (const QPainterPath &path) const
 Maps the path path, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromParent (qreal x, qreal y) const
 This convenience function is equivalent to calling mapFromParent(QPointF(x, y)). More...
 
QPolygonF mapFromParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapFromItem(QRectF(x, y, w, h)). More...
 
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 system, and returns the mapped coordinate. More...
 
QPolygonF mapFromScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromScene (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromScene (const QPainterPath &path) const
 Maps the path path, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromScene (qreal x, qreal y) const
 This convenience function is equivalent to calling mapFromScene(QPointF(x, y)). More...
 
QPolygonF mapFromScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapFromScene(QRectF(x, y, w, h)). More...
 
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, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectFromParent(QRectF(x, y, w, h)). More...
 
QRectF mapRectFromScene (const QRectF &rect) const
 Maps the rectangle rect, which is in scene coordinates, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectFromScene(QRectF(x, y, w, h)). More...
 
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, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectToParent(QRectF(x, y, w, h)). More...
 
QRectF mapRectToScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to the scene coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectToScene(QRectF(x, y, w, h)). More...
 
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, and returns the mapped coordinate. More...
 
QPolygonF mapToItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToItem (const QGraphicsItem *item, const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to item's coordinate system, and returns the mapped path. More...
 
QPointF mapToItem (const QGraphicsItem *item, qreal x, qreal y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This convenience function is equivalent to calling mapToItem(item, QPointF(x, y)). More...
 
QPolygonF mapToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapToParent (const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToParent (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToParent (const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped path. More...
 
QPointF mapToParent (qreal x, qreal y) const
 This convenience function is equivalent to calling mapToParent(QPointF(x, y)). More...
 
QPolygonF mapToParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapToParent(QRectF(x, y, w, h)). More...
 
QPointF mapToScene (const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToScene (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToScene (const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped path. More...
 
QPointF mapToScene (qreal x, qreal y) const
 This convenience function is equivalent to calling mapToScene(QPointF(x, y)). More...
 
QPolygonF mapToScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapToScene(QRectF(x, y, w, h)). More...
 
QMatrix matrix () const
 Returns the item's affine transformation matrix. More...
 
void moveBy (qreal dx, qreal dy)
 Moves the item by dx points horizontally, and dy point vertically. More...
 
qreal opacity () const
 Returns this item's local opacity, which is between 0. More...
 
QGraphicsItempanel () const
 Returns the item's panel, or 0 if this item does not have a panel. More...
 
PanelModality panelModality () const
 Returns the modality for this item. More...
 
QGraphicsItemparentItem () const
 Returns a pointer to this item's parent item. More...
 
QGraphicsObjectparentObject () const
 Returns a pointer to the item's parent, cast to a QGraphicsObject. More...
 
QGraphicsWidgetparentWidget () const
 Returns a pointer to the item's parent widget. More...
 
QPointF pos () const
 Returns the position of the item in parent coordinates. More...
 
 QGraphicsItem (QGraphicsItem *parent=0)
 Constructs a QGraphicsItem with the given parent item. More...
 
void removeSceneEventFilter (QGraphicsItem *filterItem)
 Removes an event filter on this item from filterItem. More...
 
void resetMatrix ()
 Use resetTransform() instead. More...
 
void resetTransform ()
 Resets this item's transformation matrix to the identity matrix or all the transformation properties to their default values. More...
 
void rotate (qreal angle)
 Use. More...
 
qreal rotation () const
 Returns the clockwise rotation, in degrees, around the Z axis. More...
 
void scale (qreal sx, qreal sy)
 Use. More...
 
qreal scale () const
 Returns the scale factor of the item. More...
 
QGraphicsScenescene () const
 Returns the current scene for the item, or 0 if the item is not stored in a scene. More...
 
QRectF sceneBoundingRect () const
 Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(). More...
 
QMatrix sceneMatrix () const
 Use sceneTransform() instead. More...
 
QPointF scenePos () const
 Returns the item's position in scene coordinates. More...
 
QTransform sceneTransform () const
 Returns this item's scene transformation matrix. More...
 
void scroll (qreal dx, qreal dy, const QRectF &rect=QRectF())
 Scrolls the contents of rect by dx, dy. More...
 
void setAcceptDrops (bool on)
 If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and drop events. More...
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 Sets the mouse buttons that this item accepts mouse events for. More...
 
void setAcceptHoverEvents (bool enabled)
 If enabled is true, this item will accept hover events; otherwise, it will ignore them. More...
 
void setAcceptsHoverEvents (bool enabled)
 Use setAcceptHoverEvents(enabled) instead. More...
 
void setAcceptTouchEvents (bool enabled)
 If enabled is true, this item will accept touch events; otherwise, it will ignore them. More...
 
void setActive (bool active)
 If active is true, and the scene is active, this item's panel will be activated. More...
 
void setBoundingRegionGranularity (qreal granularity)
 Sets the bounding region granularity to granularity; a value between and including 0 and 1. More...
 
void setCacheMode (CacheMode mode, const QSize &cacheSize=QSize())
 Sets the item's cache mode to mode. More...
 
void setCursor (const QCursor &cursor)
 Sets the current cursor shape for the item to cursor. More...
 
void setData (int key, const QVariant &value)
 Sets this item's custom data for the key key to value. More...
 
void setEnabled (bool enabled)
 If enabled is true, the item is enabled; otherwise, it is disabled. More...
 
void setFiltersChildEvents (bool enabled)
 If enabled is true, this item is set to filter all events for all its children (i. More...
 
void setFlag (GraphicsItemFlag flag, bool enabled=true)
 If enabled is true, the item flag flag is enabled; otherwise, it is disabled. More...
 
void setFlags (GraphicsItemFlags flags)
 Sets the item flags to flags. More...
 
void setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason)
 Gives keyboard input focus to this item. More...
 
void setFocusProxy (QGraphicsItem *item)
 Sets the item's focus proxy to item. More...
 
void setGraphicsEffect (QGraphicsEffect *effect)
 Sets effect as the item's effect. More...
 
void setGroup (QGraphicsItemGroup *group)
 Adds this item to the item group group. More...
 
void setHandlesChildEvents (bool enabled)
 If enabled is true, this item is set to handle all events for all its children (i. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 Sets the current input method hints of this item to hints. More...
 
void setMatrix (const QMatrix &matrix, bool combine=false)
 Sets the item's affine transformation matrix. More...
 
void setOpacity (qreal opacity)
 Sets this item's local opacity, between 0. More...
 
void setPanelModality (PanelModality panelModality)
 Sets the modality for this item to panelModality. More...
 
void setParentItem (QGraphicsItem *parent)
 Sets this item's parent item to newParent. More...
 
void setPos (const QPointF &pos)
 Sets the position of the item to pos, which is in parent coordinates. More...
 
void setPos (qreal x, qreal y)
 This convenience function is equivalent to calling setPos(QPointF(x, y)). More...
 
void setRotation (qreal angle)
 Sets the clockwise rotation angle, in degrees, around the Z axis. More...
 
void setScale (qreal scale)
 Sets the scale factor of the item. More...
 
void setSelected (bool selected)
 If selected is true and this item is selectable, this item is selected; otherwise, it is unselected. More...
 
void setToolTip (const QString &toolTip)
 Sets the item's tool tip to toolTip. More...
 
void setTransform (const QTransform &matrix, bool combine=false)
 Sets the item's current transformation matrix to matrix. More...
 
void setTransformations (const QList< QGraphicsTransform *> &transformations)
 Sets a list of graphics transformations (QGraphicsTransform) that currently apply to this item. More...
 
void setTransformOriginPoint (const QPointF &origin)
 Sets the origin point for the transformation in item coordinates. More...
 
void setTransformOriginPoint (qreal ax, qreal ay)
 Sets the origin point for the transformation in item coordinates. More...
 
void setVisible (bool visible)
 If visible is true, the item is made visible. More...
 
void setX (qreal x)
 Set's the x coordinate of the item's position. More...
 
void setY (qreal y)
 Set's the y coordinate of the item's position. More...
 
void setZValue (qreal z)
 Sets the Z-value of the item to z. More...
 
void shear (qreal sh, qreal sv)
 Use. More...
 
void show ()
 Shows the item. More...
 
void stackBefore (const QGraphicsItem *sibling)
 Stacks this item before sibling, which must be a sibling item (i. More...
 
QGraphicsObjecttoGraphicsObject ()
 Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object, 0 otherwise. More...
 
const QGraphicsObjecttoGraphicsObject () const
 Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object, 0 otherwise. More...
 
QString toolTip () const
 Returns the item's tool tip, or an empty QString if no tool tip has been set. More...
 
QGraphicsItemtopLevelItem () const
 Returns this item's top-level item. More...
 
QGraphicsWidgettopLevelWidget () const
 Returns a pointer to the item's top level widget (i. More...
 
QTransform transform () const
 Returns this item's transformation matrix. More...
 
QList< QGraphicsTransform * > transformations () const
 Returns a list of graphics transforms that currently apply to this item. More...
 
QPointF transformOriginPoint () const
 Returns the origin point for the transformation in item coordinates. More...
 
void translate (qreal dx, qreal dy)
 Use setPos() or setTransformOriginPoint() instead. More...
 
void ungrabKeyboard ()
 Releases the keyboard grab. More...
 
void ungrabMouse ()
 Releases the mouse grab. More...
 
void unsetCursor ()
 Clears the cursor from this item. More...
 
void update (const QRectF &rect=QRectF())
 Schedules a redraw of the area covered by rect in this item. More...
 
void update (qreal x, qreal y, qreal width, qreal height)
 This convenience function is equivalent to calling update(QRectF(x, y, width, height)). More...
 
QGraphicsWidgetwindow () const
 Returns the item's window, or 0 if this item does not have a window. More...
 
qreal x () const
 This convenience function is equivalent to calling pos(). More...
 
qreal y () const
 This convenience function is equivalent to calling pos(). More...
 
qreal zValue () const
 Returns the Z-value of the item. More...
 
virtual ~QGraphicsItem ()
 Destroys the QGraphicsItem and all its children. More...
 

Protected Functions

QVariant extension (const QVariant &variant) const
 
void setExtension (Extension extension, const QVariant &variant)
 
bool supportsExtension (Extension extension) const
 
- Protected Functions inherited from QGraphicsItem
void addToIndex ()
 Adds this item to the scene's index. More...
 
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 This event handler can be reimplemented in a subclass to process context menu events. More...
 
virtual void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drag enter events for this item. More...
 
virtual void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drag leave events for this item. More...
 
virtual void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drag move events for this item. More...
 
virtual void dropEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drop events for this item. More...
 
virtual void focusInEvent (QFocusEvent *event)
 This event handler, for event event, can be reimplemented to receive focus in events for this item. More...
 
virtual void focusOutEvent (QFocusEvent *event)
 This event handler, for event event, can be reimplemented to receive focus out events for this item. More...
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 This event handler, for event event, can be reimplemented to receive hover enter events for this item. More...
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 This event handler, for event event, can be reimplemented to receive hover leave events for this item. More...
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 This event handler, for event event, can be reimplemented to receive hover move events for this item. More...
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 This event handler, for event event, can be reimplemented to receive input method events for this item. More...
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 This method is only relevant for input items. More...
 
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 This virtual function is called by QGraphicsItem to notify custom items that some part of the item's state changes. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 This event handler, for event event, can be reimplemented to receive key press events for this item. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 This event handler, for event event, can be reimplemented to receive key release events for this item. More...
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse doubleclick events for this item. More...
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse move events for this item. More...
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse press events for this item. More...
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse release events for this item. More...
 
void prepareGeometryChange ()
 Prepares the item for a geometry change. More...
 
 QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
 
void removeFromIndex ()
 Removes this item from the scene's index. More...
 
virtual bool sceneEvent (QEvent *event)
 This virtual function receives events to this item. More...
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 Filters events for the item watched. More...
 
void updateMicroFocus ()
 Updates the item's micro focus. More...
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
 This event handler, for event event, can be reimplemented to receive wheel events for this item. More...
 

Additional Inherited Members

- Protected Types inherited from QGraphicsItem
enum  Extension { UserExtension = 0x80000000 }
 Note: This is provided as a hook to avoid future problems related to adding virtual functions. More...
 
- Protected Variables inherited from QGraphicsItem
QScopedPointer< QGraphicsItemPrivated_ptr
 

Detailed Description

The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

Since
4.2

To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's constructor, or call the setPixmap() function. The pixmap() function returns the current pixmap.

QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a reasonable implementation of boundingRect(), shape(), and contains().

graphicsview-pixmapitem.png

The pixmap is drawn at the item's (0, 0) coordinate, as returned by offset(). You can change the drawing offset by calling setOffset().

You can set the pixmap's transformation mode by calling setTransformationMode(). By default, Qt::FastTransformation is used, which provides fast, non-smooth scaling. Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the painter, and the quality depends on the platform and viewport. The result is usually not as good as calling QPixmap::scale() directly. Call transformationMode() to get the current transformation mode for the item.

See also
QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, {Graphics View Framework}

Definition at line 896 of file qgraphicsitem.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 938 of file qgraphicsitem.h.

◆ ShapeMode

This enum describes how QGraphicsPixmapItem calculates its shape and opaque area.

The default value is MaskShape.

  • MaskShape The shape is determined by calling QPixmap::mask(). This shape includes only the opaque pixels of the pixmap. Because the shape is more complex, however, it can be slower than the other modes, and uses more memory.
  • BoundingRectShape The shape is determined by tracing the outline of the pixmap. This is the fastest shape mode, but it does not take into account any transparent areas on the pixmap.
  • HeuristicMaskShape The shape is determine by calling QPixmap::createHeuristicMask(). The performance and memory consumption is similar to MaskShape.
Enumerator
MaskShape 
BoundingRectShape 
HeuristicMaskShape 

Definition at line 899 of file qgraphicsitem.h.

Constructors and Destructors

◆ QGraphicsPixmapItem() [1/2]

QGraphicsPixmapItem::QGraphicsPixmapItem ( QGraphicsItem parent = 0)

Constructs a QGraphicsPixmapItem.

parent is passed to QGraphicsItem's constructor.

See also
QGraphicsScene::addItem()

Definition at line 10117 of file qgraphicsitem.cpp.

10124 {
10125 }
QGraphicsItem(QGraphicsItem *parent=0)
Constructs a QGraphicsItem with the given parent item.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.

◆ QGraphicsPixmapItem() [2/2]

QGraphicsPixmapItem::QGraphicsPixmapItem ( const QPixmap pixmap,
QGraphicsItem parent = 0 
)

Constructs a QGraphicsPixmapItem, using pixmap as the default pixmap.

parent is passed to QGraphicsItem's constructor.

See also
QGraphicsScene::addItem()

Definition at line 10099 of file qgraphicsitem.cpp.

10107 {
10108  setPixmap(pixmap);
10109 }
QGraphicsItem(QGraphicsItem *parent=0)
Constructs a QGraphicsItem with the given parent item.
void setPixmap(const QPixmap &pixmap)
Sets the item&#39;s pixmap to pixmap.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.

◆ ~QGraphicsPixmapItem()

QGraphicsPixmapItem::~QGraphicsPixmapItem ( )

Destroys the QGraphicsPixmapItem.

Definition at line 10130 of file qgraphicsitem.cpp.

10131 {
10132 }

Functions

◆ boundingRect()

QRectF QGraphicsPixmapItem::boundingRect ( ) const
virtual

Reimplemented Function

Implements QGraphicsItem.

Definition at line 10235 of file qgraphicsitem.cpp.

10236 {
10237  Q_D(const QGraphicsPixmapItem);
10238  if (d->pixmap.isNull())
10239  return QRectF();
10240  if (d->flags & ItemIsSelectable) {
10241  qreal pw = 1.0;
10242  return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
10243  } else {
10244  return QRectF(d->offset, d->pixmap.size());
10245  }
10246 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
#define Q_D(Class)
Definition: qglobal.h:2482
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ contains()

bool QGraphicsPixmapItem::contains ( const QPointF point) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10265 of file qgraphicsitem.cpp.

10266 {
10267  return QGraphicsItem::contains(point);
10268 }
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.

◆ extension()

QVariant QGraphicsPixmapItem::extension ( const QVariant variant) const
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QGraphicsItem.

Definition at line 10359 of file qgraphicsitem.cpp.

10360 {
10361  Q_UNUSED(variant);
10362  return QVariant();
10363 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ isObscuredBy()

bool QGraphicsPixmapItem::isObscuredBy ( const QGraphicsItem item) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10291 of file qgraphicsitem.cpp.

10292 {
10293  return QGraphicsItem::isObscuredBy(item);
10294 }
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...

◆ offset()

QPointF QGraphicsPixmapItem::offset ( ) const

Returns the pixmap item's offset, which defines the point of the top-left corner of the pixmap, in local coordinates.

See also
setOffset()

Definition at line 10199 of file qgraphicsitem.cpp.

Referenced by QGraphicsEffectSource::pixmap(), and setOffset().

10200 {
10201  Q_D(const QGraphicsPixmapItem);
10202  return d->offset;
10203 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ opaqueArea()

QPainterPath QGraphicsPixmapItem::opaqueArea ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10299 of file qgraphicsitem.cpp.

10300 {
10301  return shape();
10302 }
QPainterPath shape() const
Reimplemented Function

◆ paint()

void QGraphicsPixmapItem::paint ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget 
)
virtual

Reimplemented Function

Implements QGraphicsItem.

Definition at line 10273 of file qgraphicsitem.cpp.

10275 {
10277  Q_UNUSED(widget);
10278 
10280  (d->transformationMode == Qt::SmoothTransformation));
10281 
10282  painter->drawPixmap(d->offset, d->pixmap);
10283 
10284  if (option->state & QStyle::State_Selected)
10285  qt_graphicsItem_highlightSelected(this, painter, option);
10286 }
double d
Definition: qnumeric_p.h:62
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
#define Q_D(Class)
Definition: qglobal.h:2482
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.
static void qt_graphicsItem_highlightSelected(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
Highlights item as selected.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ pixmap()

QPixmap QGraphicsPixmapItem::pixmap ( ) const

Returns the item's pixmap, or an invalid QPixmap if no pixmap has been set.

See also
setPixmap()

Definition at line 10154 of file qgraphicsitem.cpp.

Referenced by QGraphicsEffectSource::pixmap(), and setPixmap().

10155 {
10156  Q_D(const QGraphicsPixmapItem);
10157  return d->pixmap;
10158 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ setExtension()

void QGraphicsPixmapItem::setExtension ( Extension  extension,
const QVariant variant 
)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QGraphicsItem.

Definition at line 10350 of file qgraphicsitem.cpp.

10351 {
10353  Q_UNUSED(variant);
10354 }
QVariant extension(const QVariant &variant) const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setOffset() [1/2]

void QGraphicsPixmapItem::setOffset ( const QPointF offset)

Sets the pixmap item's offset to offset.

QGraphicsPixmapItem will draw its pixmap using offset for its top-left corner.

See also
offset()

Definition at line 10211 of file qgraphicsitem.cpp.

10212 {
10214  if (d->offset == offset)
10215  return;
10217  d->offset = offset;
10218  d->hasShape = false;
10219  update();
10220 }
double d
Definition: qnumeric_p.h:62
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
#define Q_D(Class)
Definition: qglobal.h:2482
void prepareGeometryChange()
Prepares the item for a geometry change.
QPointF offset() const
Returns the pixmap item&#39;s offset, which defines the point of the top-left corner of the pixmap...
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ setOffset() [2/2]

void QGraphicsPixmapItem::setOffset ( qreal  x,
qreal  y 
)
inline

This convenience function is equivalent to calling setOffset(QPointF(x, y)).

Since
4.3

Definition at line 954 of file qgraphicsitem.h.

955 { setOffset(QPointF(ax, ay)); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void setOffset(const QPointF &offset)
Sets the pixmap item&#39;s offset to offset.

◆ setPixmap()

void QGraphicsPixmapItem::setPixmap ( const QPixmap pixmap)

Sets the item's pixmap to pixmap.

See also
pixmap()

Definition at line 10139 of file qgraphicsitem.cpp.

Referenced by QGraphicsPixmapItem().

10140 {
10143  d->pixmap = pixmap;
10144  d->hasShape = false;
10145  update();
10146 }
double d
Definition: qnumeric_p.h:62
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
#define Q_D(Class)
Definition: qglobal.h:2482
QPixmap pixmap() const
Returns the item&#39;s pixmap, or an invalid QPixmap if no pixmap has been set.
void prepareGeometryChange()
Prepares the item for a geometry change.
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ setShapeMode()

void QGraphicsPixmapItem::setShapeMode ( ShapeMode  mode)

Sets the item's shape mode to mode.

The shape mode describes how QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.

See also
shapeMode(), ShapeMode

Definition at line 10329 of file qgraphicsitem.cpp.

10330 {
10332  if (d->shapeMode == mode)
10333  return;
10334  d->shapeMode = mode;
10335  d->hasShape = false;
10336 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ setTransformationMode()

void QGraphicsPixmapItem::setTransformationMode ( Qt::TransformationMode  mode)

Sets the pixmap item's transformation mode to mode, and toggles an update of the item.

The default mode is Qt::FastTransformation, which provides quick transformation with no smoothing.

Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the painter, and the quality depends on the platform and viewport. The result is usually not as good as calling QPixmap::scale() directly.

See also
transformationMode()

Definition at line 10184 of file qgraphicsitem.cpp.

10185 {
10187  if (mode != d->transformationMode) {
10188  d->transformationMode = mode;
10189  update();
10190  }
10191 }
double d
Definition: qnumeric_p.h:62
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ shape()

QPainterPath QGraphicsPixmapItem::shape ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10251 of file qgraphicsitem.cpp.

Referenced by opaqueArea().

10252 {
10253  Q_D(const QGraphicsPixmapItem);
10254  if (!d->hasShape) {
10256  thatD->updateShape();
10257  thatD->hasShape = true;
10258  }
10259  return d_func()->shape;
10260 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ shapeMode()

QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode ( ) const

Returns the item's shape mode.

The shape mode describes how QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.

See also
setShapeMode(), ShapeMode

Definition at line 10318 of file qgraphicsitem.cpp.

10319 {
10320  return d_func()->shapeMode;
10321 }

◆ supportsExtension()

bool QGraphicsPixmapItem::supportsExtension ( Extension  extension) const
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QGraphicsItem.

Definition at line 10341 of file qgraphicsitem.cpp.

10342 {
10344  return false;
10345 }
QVariant extension(const QVariant &variant) const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ transformationMode()

Qt::TransformationMode QGraphicsPixmapItem::transformationMode ( ) const

Returns the transformation mode of the pixmap.

The default mode is Qt::FastTransformation, which provides quick transformation with no smoothing.

See also
setTransformationMode()

Definition at line 10167 of file qgraphicsitem.cpp.

10168 {
10169  Q_D(const QGraphicsPixmapItem);
10170  return d->transformationMode;
10171 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.

◆ type()

int QGraphicsPixmapItem::type ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10307 of file qgraphicsitem.cpp.

10308 {
10309  return Type;
10310 }

The documentation for this class was generated from the following files: