com.trolltech.qt.gui
Class QGraphicsWidget

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QGraphicsWidget
All Implemented Interfaces:
QGraphicsItemInterface, QGraphicsLayoutItemInterface, QtJambiInterface
Direct Known Subclasses:
QGraphicsProxyWidget

public class QGraphicsWidget
extends QObject
implements QGraphicsItemInterface, QGraphicsLayoutItemInterface

The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene. QGraphicsWidget is an extended base item that provides extra functionality over QGraphicsItem. It is similar to QWidget in many ways:

Unlike QGraphicsItem, QGraphicsWidget is not an abstract class; you can create instances of a QGraphicsWidget without having to subclass it. This approach is useful for widgets that only serve the purpose of organizing child widgets into a layout.

QGraphicsWidget can be used as a base item for your own custom item if you require advanced input focus handling, e.g., tab focus and activation, or layouts.

Since QGraphicsWidget resembles QWidget and has similar API, it is easier to port a widget from QWidget to QGraphicsWidget, instead of QGraphicsItem.

Note:QWidget-based widgets can be directly embedded into a QGraphicsScene using QGraphicsProxyWidget.

Noticeable differences between QGraphicsWidget and QWidget are:

QGraphicsWidget QWidget
Coordinates and geometry are defined with qreals (doubles or floats, depending on the platform). QWidget uses integer geometry (QPoint, QRect).
The widget is already visible by default; you do not have to call show() to display the widget. QWidget is hidden by default until you call show().
A subset of widget attributes are supported. All widget attributes are supported.
A top-level item's style defaults to QGraphicsScene::style A top-level widget's style defaults to QApplication::style
Graphics View provides a custom DnD framework, different from QWidget. Standard DnD framework.
Widget items do not support modality. Full modality support.
QGraphicsWidget supports a subset of Qt's widget attributes, (Qt::WidgetAttribute ), as shown in the table below. Any attributes not listed in this table are unsupported, or otherwise unused.
Widget Attribute Usage
Qt::WA_SetLayoutDirection Set by setLayoutDirection(), cleared by unsetLayoutDirection(). You can test this attribute to check if the widget has been explicitly assigned a layoutDirection. If the attribute is not set, the layoutDirection() is inherited.
Qt::WA_RightToLeft Toggled by setLayoutDirection(). Inherited from the parent/scene. If set, the widget's layout will order horizontally arranged widgets from right to left.
Qt::WA_SetStyle Set and cleared by setStyle(). If this attribute is set, the widget has been explicitly assigned a style. If it is unset, the widget will use the scene's or the application's style.
Qt::WA_Resized Set by setGeometry() and resize().
Although QGraphicsWidget inherits from both QObject and QGraphicsItem, you should use the functions provided by QGraphicsItem, notQObject, to manage the relationships between parent and child items. These functions control the stacking order of items as well as their ownership.

Note: The QObject::parent() should always return 0 for QGraphicsWidgets, but this policy is not strictly defined.

See also:
QGraphicsProxyWidget, QGraphicsItem, and Widgets and Layouts.


Nested Class Summary
static class QGraphicsWidget.enum_1
           
 
Nested classes/interfaces inherited from class com.trolltech.qt.QtJambiObject
QtJambiObject.QPrivateConstructor
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
  QGraphicsWidget()
          Constructs a QGraphicsWidget instance.
  QGraphicsWidget(QGraphicsItemInterface parent)
          Constructs a QGraphicsWidget instance.
  QGraphicsWidget(QGraphicsItemInterface parent, Qt.WindowFlags wFlags)
          Constructs a QGraphicsWidget instance.
  QGraphicsWidget(QGraphicsItemInterface parent, Qt.WindowType... wFlags)
          Constructs a QGraphicsWidget instance.
protected QGraphicsWidget(QtJambiObject.QPrivateConstructor p)
          This method is internal to Qt Jambi.
 
Method Summary
 long __qt_cast_to_QGraphicsItem(long ptr)
          This method is internal to Qt Jambi.
 long __qt_cast_to_QGraphicsLayoutItem(long ptr)
          This method is internal to Qt Jambi.
 boolean acceptDrops()
          Returns true if this item can accept drag and drop events; otherwise, returns false.
 Qt.MouseButtons acceptedMouseButtons()
          Returns the mouse buttons that this item accepts mouse events for.
 boolean acceptHoverEvents()
          Returns true if an item accepts hover events (QGraphicsSceneHoverEvent); otherwise, returns false.
 boolean acceptsHoverEvents()
          Call acceptHoverEvents() instead.
 void addToIndex()
          This method is internal to Qt Jambi.
 void adjustSize()
          Adjusts the size of the widget to its effective minimum size hint.
 void advance(int phase)
          This virtual function is called twice for all items by the QGraphicsScene::advance() slot.
 QRectF boundingRect()
          This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be restricted to inside an item's bounding rect.
 QRegion boundingRegion(QTransform itemToDeviceTransform)
          Returns the bounding region for this item.
 double boundingRegionGranularity()
          Returns the item's bounding region granularity; a value between and including 0 and 1.
 QGraphicsItem.CacheMode cacheMode()
          Returns the cache mode for this item.
protected  void changeEvent(QEvent event)
          This event handler can be reimplemented to handle state changes.
 java.util.List<QGraphicsItemInterface> childItems()
          Returns a list of this item's children.
 QRectF childrenBoundingRect()
          Returns the bounding rect of this item's descendents (i.e., its children, their children, etc.) in local coordinates.
 void clearFocus()
          Takes keyboard input focus from the item.
 boolean close()
          Call this function to close the widget.
protected  void closeEvent(QCloseEvent event)
          This event handler, for event, can be reimplemented in a subclass to receive widget close events.
 boolean collidesWithItem(QGraphicsItemInterface other, Qt.ItemSelectionMode mode)
          Returns true if this item collides with other; otherwise returns false.
 boolean collidesWithPath(QPainterPath path, Qt.ItemSelectionMode mode)
          Returns true if this item collides with path.
 java.util.List<QGraphicsItemInterface> collidingItems(Qt.ItemSelectionMode mode)
          Returns a list of all items that collide with this item.
 QGraphicsItemInterface commonAncestorItem(QGraphicsItemInterface other)
          Returns the closest common ancestor item of this item and other, or 0 if either other is 0, or there is no common ancestor.
 boolean contains(QPointF point)
          Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
 QRectF contentsRect()
          Returns the contents rect in local coordinates.
 void contextMenuEvent(QGraphicsSceneContextMenuEvent event)
          This event handler can be reimplemented in a subclass to process context menu events.
 QCursor cursor()
          Returns the current cursor shape for the item.
 java.lang.Object data(int key)
          Returns this item's custom data for the key key as a QVariant.
 QTransform deviceTransform(QTransform viewportTransform)
          Returns this item's device transformation matrix, using viewportTransform to map from scene to device coordinates.
 void dragEnterEvent(QGraphicsSceneDragDropEvent event)
          This event handler, for event event, can be reimplemented to receive drag enter events for this item.
 void dragLeaveEvent(QGraphicsSceneDragDropEvent event)
          This event handler, for event event, can be reimplemented to receive drag leave events for this item.
 void dragMoveEvent(QGraphicsSceneDragDropEvent event)
          This event handler, for event event, can be reimplemented to receive drag move events for this item.
 void dropEvent(QGraphicsSceneDragDropEvent event)
          This event handler, for event event, can be reimplemented to receive drop events for this item.
 QSizeF effectiveSizeHint(Qt.SizeHint which, QSizeF constraint)
          Returns the effective size hint for this QGraphicsLayoutItem.
 void ensureVisible(double x, double y, double w, double h, int xmargin, int ymargin)
          This convenience function is equivalent to calling ensureVisible(QRectF(x, y, w, h), xmargin, ymargin):
 void ensureVisible(QRectF rect, int xmargin, int ymargin)
          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.
 boolean event(QEvent event)
          This method is reimplemented for internal reasons.
 java.lang.Object extension(java.lang.Object variant)
          This method is internal to Qt Jambi.
 QGraphicsItem.GraphicsItemFlags flags()
          Returns this item's flags.
 void focusInEvent(QFocusEvent event)
          This event handler, for event event, can be reimplemented to receive focus in events for this item.
protected  boolean focusNextPrevChild(boolean next)
          Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget; returns false otherwise.
 void focusOutEvent(QFocusEvent event)
          This event handler, for event event, can be reimplemented to receive focus out events for this item.
 Qt.FocusPolicy focusPolicy()
          This property holds the way the widget accepts keyboard focus.
 QGraphicsWidget focusWidget()
          If this widget, a child or descendent of this widget currently has input focus, this function will return a pointer to that widget.
 QFont font()
          This property holds the widgets' font.
static QGraphicsWidget fromNativePointer(QNativePointer nativePointer)
          This method returns the QGraphicsWidget instance pointed to by nativePointer.
 QRectF geometry()
          Returns the item's geometry (e.g., position and size) as a QRectF.
 QMarginsF getContentsMargins()
          This virtual function provides the left, top, right and bottom contents margins for this QGraphicsLayoutItem.
 QMarginsF getWindowFrameMargins()
          Gets the widget's window frame margins.
 void grabKeyboard()
          Grabs the keyboard input.
protected  void grabKeyboardEvent(QEvent event)
          This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::GrabKeyboard events.
 void grabMouse()
          Grabs the mouse input.
protected  void grabMouseEvent(QEvent event)
          This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::GrabMouse events.
 QGraphicsItemGroup group()
          Returns a pointer to this item's item group, or 0 if this item is not member of a group.
 boolean handlesChildEvents()
          Returns true if this item handles child events (i.e., all events intended for any of its children are instead sent to this item); otherwise, false is returned.
 boolean hasCursor()
          Returns true if this item has a cursor set; otherwise, false is returned.
 boolean hasFocus()
          Returns true if this item has keyboard input focus; otherwise, returns false.
 void hide()
          Hides the item.
protected  void hideEvent(QHideEvent event)
          This event handler, for Hide events, is delivered after the widget has been hidden, for example, setVisible(false) has been called for the widget or one of its ancestors when the widget was previously shown.
 void hoverEnterEvent(QGraphicsSceneHoverEvent event)
          This event handler, for event event, can be reimplemented to receive hover enter events for this item.
 void hoverLeaveEvent(QGraphicsSceneHoverEvent event)
          This event handler, for event event, can be reimplemented to receive hover leave events for this item.
 void hoverMoveEvent(QGraphicsSceneHoverEvent event)
          This event handler, for event event, can be reimplemented to receive hover move events for this item.
protected  void initStyleOption(QStyleOption option)
          Populates a style option object for this widget based on its current state, and stores the output in option.
 void inputMethodEvent(QInputMethodEvent event)
          This event handler, for event event, can be reimplemented to receive input method events for this item.
 java.lang.Object inputMethodQuery(Qt.InputMethodQuery query)
          This method is only relevant for input items.
 void installSceneEventFilter(QGraphicsItemInterface filterItem)
          Installs an event filter for this item on filterItem, causing all events for this item to first pass through filterItem's sceneEventFilter() function.
 boolean isActiveWindow()
          Returns true if this widget's window is in the active window, or if the widget does not have a window but is in an active scene (i.e., a scene that currently has focus).
 boolean isAncestorOf(QGraphicsItemInterface child)
          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).
 boolean isEnabled()
          Returns true if the item is enabled; otherwise, false is returned.
 boolean isLayout()
          Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false.
 boolean isObscured()
          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).
 boolean isObscured(double x, double y, double w, double h)
          This convenience function is equivalent to calling isObscured(QRectF(x, y, w, h)).
 boolean isObscured(QRectF rect)
          Returns true if 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).
 boolean isObscuredBy(QGraphicsItemInterface item)
          Returns true if this item's bounding rect is completely obscured by the opaque shape of item.
 boolean isSelected()
          Returns true if this item is selected; otherwise, false is returned.
 boolean isUnderMouse()
          Returns true if this item is currently under the mouse cursor in one of the views; otherwise, false is returned.
 boolean isVisible()
          Returns true if the item is visible; otherwise, false is returned.
 boolean isVisibleTo(QGraphicsItemInterface parent)
          Returns true if the item is visible to parent; otherwise, false is returned.
 boolean isWidget()
          Returns true if this item is a widget (i.e., QGraphicsWidget); otherwise, returns false.
 boolean isWindow()
          Returns true if the item is a QGraphicsWidget window, otherwise returns false.
 java.lang.Object itemChange(QGraphicsItem.GraphicsItemChange change, java.lang.Object value)
          This virtual function is called by QGraphicsItem to notify custom items that some part of the item's state changes.
 void keyPressEvent(QKeyEvent event)
          This event handler, for event event, can be reimplemented to receive key press events for this item.
 void keyReleaseEvent(QKeyEvent event)
          This event handler, for event event, can be reimplemented to receive key release events for this item.
 QGraphicsLayout layout()
          Returns this widget's layout, or 0 if no layout is currently managing this widget.
 Qt.LayoutDirection layoutDirection()
          This property holds the layout direction for this widget..
 QPointF mapFromItem(QGraphicsItemInterface item, double x, double y)
          This convenience function is equivalent to calling mapFromItem(item, QPointF(x, y)).
 QPolygonF mapFromItem(QGraphicsItemInterface item, double x, double y, double w, double h)
          This convenience function is equivalent to calling mapFromItem(item, QRectF(x, y, w, h)).
 QPainterPath mapFromItem(QGraphicsItemInterface item, QPainterPath path)
          Maps the path path, which is in item's coordinate system, to this item's coordinate system, and returns the mapped path.
 QPointF mapFromItem(QGraphicsItemInterface item, QPointF point)
          Maps the point point, which is in item's coordinate system, to this item's coordinate system, and returns the mapped coordinate.
 QPolygonF mapFromItem(QGraphicsItemInterface item, QPolygonF polygon)
          Maps the polygon polygon, which is in item's coordinate system, to this item's coordinate system, and returns the mapped polygon.
 QPolygonF mapFromItem(QGraphicsItemInterface item, QRectF rect)
          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.
 QPointF mapFromParent(double x, double y)
          This convenience function is equivalent to calling mapFromParent(QPointF(x, y)).
 QPolygonF mapFromParent(double x, double y, double w, double h)
          This convenience function is equivalent to calling mapFromItem(QRectF(x, y, w, h)).
 QPainterPath mapFromParent(QPainterPath path)
          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.
 QPointF mapFromParent(QPointF point)
          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.
 QPolygonF mapFromParent(QPolygonF polygon)
          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.
 QPolygonF mapFromParent(QRectF rect)
          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.
 QPointF mapFromScene(double x, double y)
          This convenience function is equivalent to calling mapFromScene(QPointF(x, y)).
 QPolygonF mapFromScene(double x, double y, double w, double h)
          This convenience function is equivalent to calling mapFromScene(QRectF(x, y, w, h)).
 QPainterPath mapFromScene(QPainterPath path)
          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.
 QPointF mapFromScene(QPointF point)
          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.
 QPolygonF mapFromScene(QPolygonF polygon)
          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.
 QPolygonF mapFromScene(QRectF rect)
          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.
 QPointF mapToItem(QGraphicsItemInterface item, double x, double y)
          This convenience function is equivalent to calling mapToItem(item, QPointF(x, y)).
 QPolygonF mapToItem(QGraphicsItemInterface item, double x, double y, double w, double h)
          This convenience function is equivalent to calling mapToItem(item, QRectF(x, y, w, h)).
 QPainterPath mapToItem(QGraphicsItemInterface item, QPainterPath path)
          Maps the path path, which is in this item's coordinate system, to item's coordinate system, and returns the mapped path.
 QPointF mapToItem(QGraphicsItemInterface item, QPointF point)
          Maps the point point, which is in this item's coordinate system, to item's coordinate system, and returns the mapped coordinate.
 QPolygonF mapToItem(QGraphicsItemInterface item, QPolygonF polygon)
          Maps the polygon polygon, which is in this item's coordinate system, to item's coordinate system, and returns the mapped polygon.
 QPolygonF mapToItem(QGraphicsItemInterface item, QRectF rect)
          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.
 QPointF mapToParent(double x, double y)
          This convenience function is equivalent to calling mapToParent(QPointF(x, y)).
 QPolygonF mapToParent(double x, double y, double w, double h)
          This convenience function is equivalent to calling mapToParent(QRectF(x, y, w, h)).
 QPainterPath mapToParent(QPainterPath path)
          Maps the path path, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped path.
 QPointF mapToParent(QPointF point)
          Maps the point point, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped coordinate.
 QPolygonF mapToParent(QPolygonF polygon)
          Maps the polygon polygon, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped polygon.
 QPolygonF mapToParent(QRectF rect)
          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.
 QPointF mapToScene(double x, double y)
          This convenience function is equivalent to calling mapToScene(QPointF(x, y)).
 QPolygonF mapToScene(double x, double y, double w, double h)
          This convenience function is equivalent to calling mapToScene(QRectF(x, y, w, h)).
 QPainterPath mapToScene(QPainterPath path)
          Maps the path path, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped path.
 QPointF mapToScene(QPointF point)
          Maps the point point, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped coordinate.
 QPolygonF mapToScene(QPolygonF polygon)
          Maps the polygon polygon, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped polygon.
 QPolygonF mapToScene(QRectF rect)
          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.
 double maximumHeight()
          Returns the maximum height.
 QSizeF maximumSize()
          Returns the maximum size.
 double maximumWidth()
          Returns the maximum width.
 double minimumHeight()
          Returns the minimum height.
 QSizeF minimumSize()
          Returns the minimum size.
 double minimumWidth()
          Returns the minimum width.
 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent event)
          This event handler, for event event, can be reimplemented to receive mouse doubleclick events for this item.
 void mouseMoveEvent(QGraphicsSceneMouseEvent event)
          This event handler, for event event, can be reimplemented to receive mouse move events for this item.
 void mousePressEvent(QGraphicsSceneMouseEvent event)
          This event handler, for event event, can be reimplemented to receive mouse press events for this item.
 void mouseReleaseEvent(QGraphicsSceneMouseEvent event)
          This event handler, for event event, can be reimplemented to receive mouse release events for this item.
 void moveBy(double dx, double dy)
          Moves the item by dx points horizontally, and dy point vertically.
protected  void moveEvent(QGraphicsSceneMoveEvent event)
          This event handler, for GraphicsSceneMove events, is delivered after the widget has moved (e.g., its local position has changed).
 QPainterPath opaqueArea()
          This virtual function returns a shape representing the area where this item is opaque.
 void paint(QPainter painter, QStyleOptionGraphicsItem option, QWidget widget)
          This function, which is usually called by QGraphicsView, paints the contents of an item in local coordinates.
 void paintWindowFrame(QPainter painter, QStyleOptionGraphicsItem option)
          This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates.
 void paintWindowFrame(QPainter painter, QStyleOptionGraphicsItem option, QWidget widget)
          This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates.
 QPalette palette()
          This property holds the widgets' palette.
 QGraphicsItemInterface parentItem()
          Returns a pointer to this item's parent item.
 QGraphicsLayoutItemInterface parentLayoutItem()
          Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes).
 QGraphicsWidget parentWidget()
          Returns a pointer to the item's parent widget.
protected  void polishEvent()
          This event is delivered to the item by the scene at some point after it has been constructed, but before it is shown or otherwise accessed through the scene.
 QPointF pos()
          Returns the position of the item in parent coordinates.
 double preferredHeight()
          Returns the preferred height.
 QSizeF preferredSize()
          Returns the preferred size.
 double preferredWidth()
          Returns the preferred width.
 void prepareGeometryChange()
          Prepares the item for a geometry change.
protected  java.lang.Object propertyChange(java.lang.String propertyName, java.lang.Object value)
          This method is internal to Qt Jambi.
 QRectF rect()
          Returns the item's local rect as a QRectF.
 void removeFromIndex()
          This method is internal to Qt Jambi.
 void removeSceneEventFilter(QGraphicsItemInterface filterItem)
          Removes an event filter on this item from filterItem.
 void resetTransform()
          Resets this item's transformation matrix to the identity matrix.
 void resize(double w, double h)
          This property holds the size of the widget.
 void resize(QSizeF size)
          This property holds the size of the widget.
protected  void resizeEvent(QGraphicsSceneResizeEvent event)
          This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i.e., its local size has changed).
 void rotate(double angle)
          Rotates the current item transformation angle degrees clockwise around its origin.
 void scale(double sx, double sy)
          Scales the current item transformation by (sx, sy) around its origin.
 QGraphicsScene scene()
          Returns the current scene for the item, or 0 if the item is not stored in a scene.
 QRectF sceneBoundingRect()
          Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect().
 boolean sceneEvent(QEvent event)
          This virtual function receives events to this item.
 boolean sceneEventFilter(QGraphicsItemInterface watched, QEvent event)
          Filters events for the item watched.
 QPointF scenePos()
          Returns the item's position in scene coordinates.
 QTransform sceneTransform()
          Returns this item's scene transformation matrix.
 void scroll(double dx, double dy, QRectF rect)
          Scrolls the contents of rect by dx, dy.
 void setAcceptDrops(boolean on)
          If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and drop events.
 void setAcceptedMouseButtons(Qt.MouseButtons buttons)
          Sets the mouse buttons that this item accepts mouse events for.
 void setAcceptHoverEvents(boolean enabled)
          If enabled is true, this item will accept hover events; otherwise, it will ignore them.
 void setAcceptsHoverEvents(boolean enabled)
          Use setAcceptHoverEvents(enabled) instead.
 void setAttribute(Qt.WidgetAttribute attribute)
          If on is true, this function enables attribute; otherwise attribute is disabled.
 void setAttribute(Qt.WidgetAttribute attribute, boolean on)
          If on is true, this function enables attribute; otherwise attribute is disabled.
 void setBoundingRegionGranularity(double granularity)
          Sets the bounding region granularity to granularity; a value between and including 0 and 1.
 void setCacheMode(QGraphicsItem.CacheMode mode, QSize cacheSize)
          Sets the item's cache mode to mode.
 void setContentsMargins(double left, double top, double right, double bottom)
          Sets the widget's contents margins to left, top, right and bottom.
 void setCursor(QCursor cursor)
          Sets the current cursor shape for the item to cursor.
 void setData(int key, java.lang.Object value)
          Sets this item's custom data for the key key to value.
 void setEnabled(boolean enabled)
          If enabled is true, the item is enabled; otherwise, it is disabled.
 void setExtension(QGraphicsItem.Extension extension, java.lang.Object variant)
          This method is internal to Qt Jambi.
 void setFlag(QGraphicsItem.GraphicsItemFlag flag, boolean enabled)
          If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
 void setFlags(QGraphicsItem.GraphicsItemFlags flags)
          Sets the item flags to flags.
 void setFocus(Qt.FocusReason focusReason)
          Gives keyboard input focus to this item.
 void setFocusPolicy(Qt.FocusPolicy policy)
          This property holds the way the widget accepts keyboard focus.
 void setFont(QFont font)
          This property holds the widgets' font.
 void setGeometry(double x, double y, double w, double h)
          This convenience function is equivalent to calling setGeometry(QRectF( x, y, w, h)).
 void setGeometry(QRectF rect)
          This pure virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e.g., the top-left corner of rect is equivalent to the item's position in parent coordinates).
 void setGroup(QGraphicsItemGroup group)
          Adds this item to the item group group.
 void setHandlesChildEvents(boolean enabled)
          If enabled is true, this item is set to handle all events for all its children (i.e., all events intented for any of its children are instead sent to this item); otherwise, if enabled is false, this item will only handle its own events.
 void setLayout(QGraphicsLayout layout)
          Sets the layout for this widget to layout.
 void setLayoutDirection(Qt.LayoutDirection direction)
          This property holds the layout direction for this widget..
 void setMaximumHeight(double height)
          Sets the maximum height to height.
 void setMaximumSize(double w, double h)
          This convenience function is equivalent to calling setMaximumSize(QSizeF(w, h)).
 void setMaximumSize(QSizeF size)
          Sets the maximum size to size.
 void setMaximumWidth(double width)
          Sets the maximum width to width.
 void setMinimumHeight(double height)
          Sets the minimum height to height.
 void setMinimumSize(double w, double h)
          This convenience function is equivalent to calling setMinimumSize(QSizeF(w, h)).
 void setMinimumSize(QSizeF size)
          Sets the minimum size to size.
 void setMinimumWidth(double width)
          Sets the minimum width to width.
 void setPalette(QPalette palette)
          This property holds the widgets' palette.
 void setParentItem(QGraphicsItemInterface parent)
          Sets this item's parent item to parent.
 void setParentLayoutItem(QGraphicsLayoutItemInterface parent)
          Sets the parent of this QGraphicsLayoutItem to parent.
 void setPos(double x, double y)
          This convenience function is equivalent to calling setPos(QPointF(x, y)).
 void setPos(QPointF pos)
          Sets the position of the item to pos, which is in parent coordinates.
 void setPreferredHeight(double height)
          Sets the preferred height to height.
 void setPreferredSize(double w, double h)
          This convenience function is equivalent to calling setPreferredSize(QSizeF(w, h)).
 void setPreferredSize(QSizeF size)
          Sets the preferred size to size.
 void setPreferredWidth(double width)
          Sets the preferred width to width.
 void setSelected(boolean selected)
          If selected is true and this item is selectable, this item is selected; otherwise, it is unselected.
 void setSizePolicy(QSizePolicy.Policy hPolicy, QSizePolicy.Policy vPolicy, QSizePolicy.ControlType controlType)
          This function is equivalent to calling setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)).
 void setSizePolicy(QSizePolicy policy)
          Sets the size policy to policy.
 void setStyle(QStyle style)
          Sets the widget's style to style.
static void setTabOrder(QGraphicsWidget first, QGraphicsWidget second)
          Moves the second widget around the ring of focus widgets so that keyboard focus moves from the first widget to the second widget when the Tab key is pressed.
 void setToolTip(java.lang.String toolTip)
          Sets the item's tool tip to toolTip.
 void setTransform(QTransform matrix, boolean combine)
          Sets the item's current transformation matrix to matrix.
 void setVisible(boolean visible)
          If visible is true, the item is made visible.
 void setWindowFlags(Qt.WindowFlags wFlags)
          This property holds This propery holds the widget's window flags..
 void setWindowFlags(Qt.WindowType... wFlags)
          This property holds This propery holds the widget's window flags..
 void setWindowFrameMargins(double left, double top, double right, double bottom)
          Sets the widget's window frame margins to left, top, right and bottom.
 void setWindowTitle(java.lang.String title)
          This property holds This property holds the window title (caption)..
 void setZValue(double z)
          Sets the Z-value, or the elevation, of the item, to z.
 QPainterPath shape()
          Returns the shape of this item as a QPainterPath in local coordinates.
 void shear(double sh, double sv)
          Shears the current item transformation by (sh, sv).
 void show()
          Shows the item.
protected  void showEvent(QShowEvent event)
          This event handler, for Show events, is delivered before the widget has been shown, for example, setVisible(true) has been called for the widget or one of its ancestors when the widget was previously hidden.
 QSizeF size()
          This property holds the size of the widget.
 QSizeF sizeHint(Qt.SizeHint which, QSizeF constraint)
          This pure virtual function returns the size hint for which of the QGraphicsLayoutItem, using the width or height of constraint to constrain the output.
 QSizePolicy sizePolicy()
          Returns the current size policy.
 QStyle style()
          Returns a pointer to the widget's style.
 boolean supportsExtension(QGraphicsItem.Extension extension)
          This method is internal to Qt Jambi.
 boolean testAttribute(Qt.WidgetAttribute attribute)
          Returns true if attribute is enabled for this widget; otherwise, returns false.
 java.lang.String toolTip()
          Returns the item's tool tip, or an empty QString if no tool tip has been set.
 QGraphicsItemInterface topLevelItem()
          Returns this item's top-level item.
 QGraphicsWidget topLevelWidget()
          Returns a pointer to the item's top level widget (i.e., the item's ancestor whose parent is 0, or whose parent is not a widget), or 0 if this item does not have a top level widget.
 QTransform transform()
          Returns this item's transformation matrix.
 void translate(double dx, double dy)
          Translates the current item transformation by (dx, dy).
 int type()
          Returns the type of an item as an int.
 void ungrabKeyboard()
          Releases the keyboard grab.
protected  void ungrabKeyboardEvent(QEvent event)
          This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::UngrabKeyboard events.
 void ungrabMouse()
          Releases the mouse grab.
protected  void ungrabMouseEvent(QEvent event)
          This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::UngrabMouse events.
 void unsetCursor()
          Clears the cursor from this item.
 void unsetLayoutDirection()
          This property holds the layout direction for this widget..
 void unsetWindowFrameMargins()
          Resets the window frame margins to the default value, provided by the style.
 void update(double x, double y, double width, double height)
          This convenience function is equivalent to calling update(QRectF(x, y, width, height)).
 void update(QRectF rect)
          Schedules a redraw of the area covered by rect in this item.
 void updateGeometry()
          This virtual function discards any cached size hint information.
 void wheelEvent(QGraphicsSceneWheelEvent event)
          This event handler, for event event, can be reimplemented to receive wheel events for this item.
 QGraphicsWidget window()
          Returns the item's window, or 0 if this item does not have a window.
 Qt.WindowFlags windowFlags()
          This property holds This propery holds the widget's window flags..
protected  boolean windowFrameEvent(QEvent e)
          This event handler, for event, receives events for the window frame if this widget is a window.
 QRectF windowFrameGeometry()
          Returns the widget's geometry in parent coordinates including any window frame.
 QRectF windowFrameRect()
          Returns the widget's local rect including any window frame.
protected  Qt.WindowFrameSection windowFrameSectionAt(QPointF pos)
          Returns the window frame section at position pos, or Qt::NoWindowFrameSection if there is no window frame section at this position.
 java.lang.String windowTitle()
          This property holds This property holds the window title (caption)..
 Qt.WindowType windowType()
          Returns the widgets window type.
 double x()
          This convenience function is equivalent to calling pos().x().
 double y()
          This convenience function is equivalent to calling pos().y().
 double zValue()
          Returns the Z-value, or the elevation, of the item.
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent, toString, userProperty
 
Methods inherited from class com.trolltech.qt.QtJambiObject
disableGarbageCollection, dispose, disposed, equals, finalize, nativeId, nativePointer, reassignNativeResources, reenableGarbageCollection, setJavaOwnership, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
__qt_signalInitialization, disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QGraphicsWidget

public QGraphicsWidget(QGraphicsItemInterface parent,
                       Qt.WindowType... wFlags)
Constructs a QGraphicsWidget instance. The optional parent argument is passed to QGraphicsItem's constructor. The optional wFlags argument specifies the widget's window flags (e.g., whether the widget should be a window, a tool, a popup, etc).


QGraphicsWidget

public QGraphicsWidget(QGraphicsItemInterface parent)
Constructs a QGraphicsWidget instance. The optional parent argument is passed to QGraphicsItem's constructor. The optional wFlags argument specifies the widget's window flags (e.g., whether the widget should be a window, a tool, a popup, etc).


QGraphicsWidget

public QGraphicsWidget()
Constructs a QGraphicsWidget instance. The optional parent argument is passed to QGraphicsItem's constructor. The optional wFlags argument specifies the widget's window flags (e.g., whether the widget should be a window, a tool, a popup, etc).


QGraphicsWidget

public QGraphicsWidget(QGraphicsItemInterface parent,
                       Qt.WindowFlags wFlags)
Constructs a QGraphicsWidget instance. The optional parent argument is passed to QGraphicsItem's constructor. The optional wFlags argument specifies the widget's window flags (e.g., whether the widget should be a window, a tool, a popup, etc).


QGraphicsWidget

protected QGraphicsWidget(QtJambiObject.QPrivateConstructor p)
This method is internal to Qt Jambi.

Method Detail

acceptDrops

public final boolean acceptDrops()
Returns true if this item can accept drag and drop events; otherwise, returns false. By default, items do not accept drag and drop events; items are transparent to drag and drop.

See also:
setAcceptDrops().

Specified by:
acceptDrops in interface QGraphicsItemInterface

acceptHoverEvents

public final boolean acceptHoverEvents()
Returns true if an item accepts hover events (QGraphicsSceneHoverEvent); otherwise, returns false. By default, items do not accept hover events.

See also:
setAcceptHoverEvents(), and setAcceptedMouseButtons().

Specified by:
acceptHoverEvents in interface QGraphicsItemInterface

acceptedMouseButtons

public final Qt.MouseButtons acceptedMouseButtons()
Returns the mouse buttons that this item accepts mouse events for. By default, all mouse buttons are accepted.

If an item accepts a mouse button, it will become the mouse grabber item when a mouse press event is delivered for that mouse button. However, if the item does not accept the button, QGraphicsScene will forward the mouse events to the first item beneath it that does.

See also:
setAcceptedMouseButtons(), and mousePressEvent().

Specified by:
acceptedMouseButtons in interface QGraphicsItemInterface

acceptsHoverEvents

public final boolean acceptsHoverEvents()
Call acceptHoverEvents() instead.

See also:
setAcceptsHoverEvents().

Specified by:
acceptsHoverEvents in interface QGraphicsItemInterface

addToIndex

public final void addToIndex()
This method is internal to Qt Jambi.

Specified by:
addToIndex in interface QGraphicsItemInterface

adjustSize

public final void adjustSize()
Adjusts the size of the widget to its effective minimum size hint.

This function is called implicitly when the item is shown for the first time.

See also:
effectiveSizeHint(), and Qt::MinimumSize .


boundingRegion

public final QRegion boundingRegion(QTransform itemToDeviceTransform)
Returns the bounding region for this item. The coordinate space of the returned region depends on itemToDeviceTransform. If you pass an identity QTransform as a parameter, this function will return a local coordinate region.

The bounding region describes a coarse outline of the item's visual contents. Although it's expensive to calculate, it's also more precise than boundingRect(), and it can help to avoid unnecessary repainting when an item is updated. This is particularily efficient for thin items (e.g., lines or simple polygons). You can tune the granularity for the bounding region by calling setBoundingRegionGranularity(). The default granularity is 0; in which the item's bounding region is the same as its bounding rect.

itemToDeviceTransform is the transformation from item coordinates to device coordinates. If you want this function to return a QRegion in scene coordinates, you can pass sceneTransform() as an argument.

See also:
boundingRegionGranularity().

Specified by:
boundingRegion in interface QGraphicsItemInterface

boundingRegionGranularity

public final double boundingRegionGranularity()
Returns the item's bounding region granularity; a value between and including 0 and 1. The default value is 0 (i.e., the lowest granularity, where the bounding region corresponds to the item's bounding rectangle).

See also:
setBoundingRegionGranularity().

Specified by:
boundingRegionGranularity in interface QGraphicsItemInterface

cacheMode

public final QGraphicsItem.CacheMode cacheMode()
Returns the cache mode for this item. The default mode is NoCache (i.e., cache is disabled and all painting is immediate).

See also:
setCacheMode().

Specified by:
cacheMode in interface QGraphicsItemInterface

childItems

public final java.util.List<QGraphicsItemInterface> childItems()
Returns a list of this item's children. The items are returned in no particular order.

See also:
setParentItem().

Specified by:
childItems in interface QGraphicsItemInterface

childrenBoundingRect

public final QRectF childrenBoundingRect()
Returns the bounding rect of this item's descendents (i.e., its children, their children, etc.) in local coordinates. If the item has no children, this function returns an empty QRectF.

This does not include this item's own bounding rect; it only returns its descendents' accumulated bounding rect. If you need to include this item's bounding rect, you can add boundingRect() to childrenBoundingRect() using QRectF::operator|().

This function is linear in complexity; it determines the size of the returned bounding rect by iterating through all descendents.

See also:
boundingRect(), and sceneBoundingRect().

Specified by:
childrenBoundingRect in interface QGraphicsItemInterface

clearFocus

public final void clearFocus()
Takes keyboard input focus from the item.

If it has focus, a focus out event is sent to this item to tell it that it is about to lose the focus.

Only items that set the ItemIsFocusable flag, or widgets that set an appropriate focus policy, can accept keyboard focus.

See also:
setFocus(), and QGraphicsWidget::focusPolicy.

Specified by:
clearFocus in interface QGraphicsItemInterface

close

public final boolean close()
Call this function to close the widget.

Returns true if the widget was closed; otherwise returns false. This slot will first send a QCloseEvent to the widget, which may or may not accept the event. If the event was ignored, nothing happens. If the event was accepted, it will hide() the widget.

If the widget has the Qt::WA_DeleteOnClose attribute set it will be deleted.


collidingItems

public final java.util.List<QGraphicsItemInterface> collidingItems(Qt.ItemSelectionMode mode)
Returns a list of all items that collide with this item.

The way collisions are detected is determined by mode. The default value for mode is Qt::IntersectsItemShape ; All items whose shape intersects or is contained by this item's shape are returned.

See also:
QGraphicsScene::collidingItems(), and collidesWithItem().

Specified by:
collidingItems in interface QGraphicsItemInterface

commonAncestorItem

public final QGraphicsItemInterface commonAncestorItem(QGraphicsItemInterface other)
Returns the closest common ancestor item of this item and other, or 0 if either other is 0, or there is no common ancestor.

See also:
isAncestorOf().

Specified by:
commonAncestorItem in interface QGraphicsItemInterface

contentsRect

public final QRectF contentsRect()
Returns the contents rect in local coordinates.

The contents rect defines the subrectangle used by an associated layout when arranging subitems. This function is a convenience function that adjusts the item's geometry() by its contents margins. Note that getContentsMargins() is a virtual function that you can reimplement to return the item's contents margins.

See also:
getContentsMargins(), and geometry().

Specified by:
contentsRect in interface QGraphicsLayoutItemInterface

cursor

public final QCursor cursor()
Returns the current cursor shape for the item. The mouse cursor will assume this shape when it's over this item. See the list of predefined cursor objects for a range of useful shapes.

An editor item might want to use an I-beam cursor:

The following code example is written in c++.

        item->setCursor(Qt::IBeamCursor);
If no cursor has been set, the parent's cursor is used.

See also:
setCursor(), hasCursor(), unsetCursor(), QWidget::cursor, and QApplication::overrideCursor().

Specified by:
cursor in interface QGraphicsItemInterface

data

public final java.lang.Object data(int key)
Returns this item's custom data for the key key as a QVariant.

Custom item data is useful for storing arbitrary properties in any item. Example:

The following code example is written in c++.

        static const int ObjectName = 0;

        QGraphicsItem *item = scene.itemAt(100, 50);
        if (item->data(ObjectName).toString().isEmpty()) {
            if (qgraphicsitem_cast<ButtonItem *>(item))
                item->setData(ObjectName, "Button");
        }
Qt does not use this feature for storing data; it is provided solely for the convenience of the user.

See also:
setData().

Specified by:
data in interface QGraphicsItemInterface

deviceTransform

public final QTransform deviceTransform(QTransform viewportTransform)
Returns this item's device transformation matrix, using viewportTransform to map from scene to device coordinates. This matrix can be used to map coordinates and geometrical shapes from this item's local coordinate system to the viewport's (or any device's) coordinate system. To map coordinates from the viewport, you must first invert the returned matrix.

Example:

The following code example is written in c++.

        QGraphicsRectItem rect;
        rect.setPos(100, 100);

        rect.deviceTransform(view->viewportTransform()).map(QPointF(0, 0));
        // returns the item's (0, 0) point in view's viewport coordinates

        rect.deviceTransform(view->viewportTransform()).inverted().map(QPointF(100, 100));
        // returns view's viewport's (100, 100) coordinate in item coordinates
This function is the same as combining this item's scene transform with the view's viewport transform, but is also understands ItemIgnoresTransformations .

See also:
transform(), setTransform(), scenePos(), and The Graphics View Coordinate System.

Specified by:
deviceTransform in interface QGraphicsItemInterface

effectiveSizeHint

public final QSizeF effectiveSizeHint(Qt.SizeHint which,
                                      QSizeF constraint)
Returns the effective size hint for this QGraphicsLayoutItem.

which is the size hint in question. constraint is an optional argument that defines a special constrain when calculating the effective size hint. By default, constraint is QSizeF(-1, -1), which means there is no constraint to the size hint.

If you want to specify the widget's size hint for a given width or height, you can provide the fixed dimension in constraint. This is useful for widgets that can grow only either vertically or horizontally, and need to set either their width or their height to a special value.

For example, a text paragraph item fit into a column width of 200 may grow vertically. You can pass QSizeF(200, -1) as a constraint to get a suitable minimum, preferred and maximum height).

You can adjust the effective size hint by reimplementing sizeHint() in a QGraphicsLayoutItem subclass, or by calling one of the following functions: setMinimumSize(), setPreferredSize, or setMaximumSize() (or a combination of both).

This function caches each of the size hints and guarantees that sizeHint() will be called only once for each value of which - unless constraint is not specified and updateGeometry() has been called.

See also:
sizeHint().

Specified by:
effectiveSizeHint in interface QGraphicsLayoutItemInterface

ensureVisible

public final void ensureVisible(QRectF rect,
                                int xmargin,
                                int ymargin)
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. If rect is a null rect (the default), QGraphicsItem will default to the item's bounding rect. xmargin and ymargin are the number of pixels the view should use for margins.

If the specified rect cannot be reached, the contents are scrolled to the nearest valid position.

If this item is not viewed by a QGraphicsView, this function does nothing.

See also:
QGraphicsView::ensureVisible().

Specified by:
ensureVisible in interface QGraphicsItemInterface

ensureVisible

public final void ensureVisible(double x,
                                double y,
                                double w,
                                double h,
                                int xmargin,
                                int ymargin)
This convenience function is equivalent to calling ensureVisible(QRectF(x, y, w, h), xmargin, ymargin):

Specified by:
ensureVisible in interface QGraphicsItemInterface

flags

public final QGraphicsItem.GraphicsItemFlags flags()
Returns this item's flags. The flags describe what configurable features of the item are enabled and not. For example, if the flags include ItemIsFocusable , the item can accept input focus.

By default, no flags are enabled.

See also:
setFlags(), and setFlag().

Specified by:
flags in interface QGraphicsItemInterface

focusPolicy

public final Qt.FocusPolicy focusPolicy()
This property holds the way the widget accepts keyboard focus. The focus policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it does not accept focus at all.

You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus ).

If you enable a focus policy (i.e., not Qt::NoFocus ), QGraphicsWidget will automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a widget will clear the ItemIsFocusable flag. If the widget currently has keyboard focus, the widget will automatically lose focus.

See also:
focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), and enabled.


focusWidget

public final QGraphicsWidget focusWidget()
If this widget, a child or descendent of this widget currently has input focus, this function will return a pointer to that widget. If no descendent has input focus, 0 is returned.

See also:
QWidget::focusWidget().


font

public final QFont font()
This property holds the widgets' font. This property provides the widget's font.

QFont consists of font properties that have been explicitly defined and properties implicitly inherited from the widget's parent. Hence, font() can return a different font compared to the one set with setFont(). This scheme allows you to define single entries in a font without affecting the font's inherited entries.

When a widget's font changes, it resolves its entries against its parent widget. If the widget does not have a parent widget, it resolves its entries against the scene. The widget then sends itself a FontChange event and notifies all its descendants so that they can resolve their fonts as well.

See also:
QApplication::font(), QGraphicsScene::font, and QFont::resolve().


geometry

public final QRectF geometry()
Returns the item's geometry (e.g., position and size) as a QRectF. This function is equivalent to QRectF(pos(), size()).

See also:
setGeometry().

Specified by:
geometry in interface QGraphicsLayoutItemInterface

grabKeyboard

public final void grabKeyboard()
Grabs the keyboard input.

The item will receive all keyboard input to the scene until one of the following events occur:

When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard event. When it loses the keyboard grab, it receives a QEvent::UngrabKeyboard event. These events can be used to detect when your item gains or loses the keyboard grab through other means than gaining input focus.

It is almost never necessary to explicitly grab the keyboard in Qt, as Qt grabs and releases it sensibly. In particular, Qt grabs the keyboard when your item gains input focus, and releases it when your item loses input focus, or when the item is hidden.

Note that only visible items can grab keyboard input. Calling grabKeyboard() on an invisible item has no effect.

Keyboard events are not affected.

See also:
ungrabKeyboard(), grabMouse(), and setFocus().

Specified by:
grabKeyboard in interface QGraphicsItemInterface

grabMouse

public final void grabMouse()
Grabs the mouse input.

This item will receive all mouse events for the scene until any of the following events occurs:

When an item gains the mouse grab, it receives a QEvent::GrabMouse event. When it loses the mouse grab, it receives a QEvent::UngrabMouse event. These events can be used to detect when your item gains or loses the mouse grab through other means than receiving mouse button events.

It is almost never necessary to explicitly grab the mouse in Qt, as Qt grabs and releases it sensibly. In particular, Qt grabs the mouse when you press a mouse button, and keeps the mouse grabbed until you release the last mouse button. Also, Qt::Popup widgets implicitly call grabMouse() when shown, and ungrabMouse() when hidden.

Note that only visible items can grab mouse input. Calling grabMouse() on an invisible item has no effect.

Keyboard events are not affected.

See also:
QGraphicsScene::mouseGrabberItem(), ungrabMouse(), and grabKeyboard().

Specified by:
grabMouse in interface QGraphicsItemInterface

group

public final QGraphicsItemGroup group()
Returns a pointer to this item's item group, or 0 if this item is not member of a group.

See also:
setGroup(), QGraphicsItemGroup, and QGraphicsScene::createItemGroup().

Specified by:
group in interface QGraphicsItemInterface

handlesChildEvents

public final boolean handlesChildEvents()
Returns true if this item handles child events (i.e., all events intended for any of its children are instead sent to this item); otherwise, false is returned.

This property is useful for item groups; it allows one item to handle events on behalf of its children, as opposed to its children handling their events individually.

The default is to return false; children handle their own events. The exception for this is if the item is a QGraphicsItemGroup, then it defaults to return true.

See also:
setHandlesChildEvents().

Specified by:
handlesChildEvents in interface QGraphicsItemInterface

hasCursor

public final boolean hasCursor()
Returns true if this item has a cursor set; otherwise, false is returned.

By default, items don't have any cursor set. cursor() will return a standard pointing arrow cursor.

See also:
unsetCursor().

Specified by:
hasCursor in interface QGraphicsItemInterface

hasFocus

public final boolean hasFocus()
Returns true if this item has keyboard input focus; otherwise, returns false.

See also:
focusWidget(), QGraphicsScene::focusItem(), setFocus(), and QGraphicsScene::setFocusItem().

Specified by:
hasFocus in interface QGraphicsItemInterface

hide

public final void hide()
Hides the item. (Items are visible by default.)

This convenience function is equivalent to calling setVisible(false).

See also:
show(), and setVisible().

Specified by:
hide in interface QGraphicsItemInterface

installSceneEventFilter

public final void installSceneEventFilter(QGraphicsItemInterface filterItem)
Installs an event filter for this item on filterItem, causing all events for this item to first pass through filterItem's sceneEventFilter() function.

To filter another item's events, install this item as an event filter for the other item. Example:

The following code example is written in c++.

        QGraphicsScene scene;
        QGraphicsEllipseItem *ellipse = scene.addEllipse(QRectF(-10, -10, 20, 20));
        QGraphicsLineItem *line = scene.addLine(QLineF(-10, -10, 20, 20));

        line->installSceneEventFilter(ellipse);
        // line's events are filtered by ellipse's sceneEventFilter() function.

        ellipse->installSceneEventFilter(line);
        // ellipse's events are filtered by line's sceneEventFilter() function.
An item can only filter events for other items in the same scene. Also, an item cannot filter its own events; instead, you can reimplement sceneEvent() directly.

Items must belong to a scene for scene event filters to be installed and used.

See also:
removeSceneEventFilter(), sceneEventFilter(), and sceneEvent().

Specified by:
installSceneEventFilter in interface QGraphicsItemInterface

isActiveWindow

public final boolean isActiveWindow()
Returns true if this widget's window is in the active window, or if the widget does not have a window but is in an active scene (i.e., a scene that currently has focus).

The active window is the window that either contains a child widget that currently has input focus, or that itself has input focus.

See also:
QGraphicsScene::activeWindow(), and QGraphicsScene::setActiveWindow().


isAncestorOf

public final boolean isAncestorOf(QGraphicsItemInterface child)
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).

See also:
parentItem().

Specified by:
isAncestorOf in interface QGraphicsItemInterface

isEnabled

public final boolean isEnabled()
Returns true if the item is enabled; otherwise, false is returned.

See also:
setEnabled().

Specified by:
isEnabled in interface QGraphicsItemInterface

isLayout

public final boolean isLayout()
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false.

See also:
QGraphicsLayout.

Specified by:
isLayout in interface QGraphicsLayoutItemInterface

isObscured

public final boolean isObscured()
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).

Its implementation is based on calling isObscuredBy(), which you can reimplement to provide a custom obscurity algorithm.

See also:
opaqueArea().

Specified by:
isObscured in interface QGraphicsItemInterface

isObscured

public final boolean isObscured(QRectF rect)
Returns true if 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).

Unlike the default isObscured() function, this function does not call isObscuredBy().

See also:
opaqueArea().

Specified by:
isObscured in interface QGraphicsItemInterface

isObscured

public final boolean isObscured(double x,
                                double y,
                                double w,
                                double h)
This convenience function is equivalent to calling isObscured(QRectF(x, y, w, h)).

Specified by:
isObscured in interface QGraphicsItemInterface

isSelected

public final boolean isSelected()
Returns true if this item is selected; otherwise, false is returned.

Items that are in a group inherit the group's selected state.

Items are not selected by default.

See also:
setSelected(), and QGraphicsScene::setSelectionArea().

Specified by:
isSelected in interface QGraphicsItemInterface

isUnderMouse

public final boolean isUnderMouse()
Returns true if this item is currently under the mouse cursor in one of the views; otherwise, false is returned.

See also:
QGraphicsScene::views(), and QCursor::pos().

Specified by:
isUnderMouse in interface QGraphicsItemInterface

isVisible

public final boolean isVisible()
Returns true if the item is visible; otherwise, false is returned.

Note that the item's general visibility is unrelated to whether or not it is actually being visualized by a QGraphicsView.

See also:
setVisible().

Specified by:
isVisible in interface QGraphicsItemInterface

isVisibleTo

public final boolean isVisibleTo(QGraphicsItemInterface parent)
Returns true if the item is visible to parent; otherwise, false is returned. parent can be 0, in which case this function will return whether the item is visible to the scene or not.

An item may not be visible to its ancestors even if isVisible() is true. If any ancestor is hidden, the item itself will be implicitly hidden, in which case this function will return false.

See also:
isVisible(), and setVisible().

Specified by:
isVisibleTo in interface QGraphicsItemInterface

isWidget

public final boolean isWidget()
Returns true if this item is a widget (i.e., QGraphicsWidget); otherwise, returns false.

Specified by:
isWidget in interface QGraphicsItemInterface

isWindow

public final boolean isWindow()
Returns true if the item is a QGraphicsWidget window, otherwise returns false.

See also:
QGraphicsWidget::windowFlags().

Specified by:
isWindow in interface QGraphicsItemInterface

layout

public final QGraphicsLayout layout()
Returns this widget's layout, or 0 if no layout is currently managing this widget.

See also:
setLayout().


layoutDirection

public final Qt.LayoutDirection layoutDirection()
This property holds the layout direction for this widget.. This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.

The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt::LeftToRight , the layout starts placing subwidgets from the left side of this widget towards the right. Qt::RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.

Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling setLayoutDirection(), the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.

See also:
QWidget::layoutDirection, and QApplication::layoutDirection.


mapFromItem

public final QPainterPath mapFromItem(QGraphicsItemInterface item,
                                      QPainterPath path)
Maps the path path, which is in item's coordinate system, to this item's coordinate system, and returns the mapped path.

If item is 0, this function returns the same as mapFromScene().

See also:
mapFromParent(), mapFromScene(), mapToItem(), and The Graphics View Coordinate System.

Specified by:
mapFromItem in interface QGraphicsItemInterface

mapFromItem

public final QPointF mapFromItem(QGraphicsItemInterface item,
                                 QPointF point)
Maps the point point, which is in item's coordinate system, to this item's coordinate system, and returns the mapped coordinate.

If item is 0, this function returns the same as mapFromScene().

See also:
mapFromParent(), mapFromScene(), transform(), mapToItem(), and The Graphics View Coordinate System.

Specified by:
mapFromItem in interface QGraphicsItemInterface

mapFromItem

public final QPolygonF mapFromItem(QGraphicsItemInterface item,
                                   QPolygonF polygon)
Maps the polygon polygon, which is in item's coordinate system, to this item's coordinate system, and returns the mapped polygon.

If item is 0, this function returns the same as mapFromScene().

See also:
mapToItem(), mapFromParent(), transform(), and The Graphics View Coordinate System.

Specified by:
mapFromItem in interface QGraphicsItemInterface

mapFromItem

public final QPolygonF mapFromItem(QGraphicsItemInterface item,
                                   QRectF rect)
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.

If item is 0, this function returns the same as mapFromScene()

See also:
mapToItem(), mapFromParent(), transform(), and The Graphics View Coordinate System.

Specified by:
mapFromItem in interface QGraphicsItemInterface

mapFromItem

public final QPointF mapFromItem(QGraphicsItemInterface item,
                                 double x,
                                 double y)
This convenience function is equivalent to calling mapFromItem(item, QPointF(x, y)).

Specified by:
mapFromItem in interface QGraphicsItemInterface

mapFromItem

public final QPolygonF mapFromItem(QGraphicsItemInterface item,
                                   double x,
                                   double y,
                                   double w,
                                   double h)
This convenience function is equivalent to calling mapFromItem(item, QRectF(x, y, w, h)).

Specified by:
mapFromItem in interface QGraphicsItemInterface

mapFromParent

public final QPainterPath mapFromParent(QPainterPath path)
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.

See also:
mapFromScene(), mapFromItem(), mapToParent(), and The Graphics View Coordinate System.

Specified by:
mapFromParent in interface QGraphicsItemInterface

mapFromParent

public final QPointF mapFromParent(QPointF point)
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.

See also:
mapFromItem(), mapFromScene(), transform(), mapToParent(), and The Graphics View Coordinate System.

Specified by:
mapFromParent in interface QGraphicsItemInterface

mapFromParent

public final QPolygonF mapFromParent(QPolygonF polygon)
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.

See also:
mapToParent(), mapToItem(), transform(), and The Graphics View Coordinate System.

Specified by:
mapFromParent in interface QGraphicsItemInterface

mapFromParent

public final QPolygonF mapFromParent(QRectF rect)
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.

See also:
mapToParent(), mapFromItem(), transform(), and The Graphics View Coordinate System.

Specified by:
mapFromParent in interface QGraphicsItemInterface

mapFromParent

public final QPointF mapFromParent(double x,
                                   double y)
This convenience function is equivalent to calling mapFromParent(QPointF(x, y)).

Specified by:
mapFromParent in interface QGraphicsItemInterface

mapFromParent

public final QPolygonF mapFromParent(double x,
                                     double y,
                                     double w,
                                     double h)
This convenience function is equivalent to calling mapFromItem(QRectF(x, y, w, h)).

Specified by:
mapFromParent in interface QGraphicsItemInterface

mapFromScene

public final QPainterPath mapFromScene(QPainterPath path)
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.

See also:
mapFromParent(), mapFromItem(), mapToScene(), and The Graphics View Coordinate System.

Specified by:
mapFromScene in interface QGraphicsItemInterface

mapFromScene

public final QPointF mapFromScene(QPointF point)
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.

See also:
mapFromItem(), mapFromParent(), transform(), mapToScene(), and The Graphics View Coordinate System.

Specified by:
mapFromScene in interface QGraphicsItemInterface

mapFromScene

public final QPolygonF mapFromScene(QPolygonF polygon)
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.

See also:
mapToScene(), mapFromParent(), transform(), and The Graphics View Coordinate System.

Specified by:
mapFromScene in interface QGraphicsItemInterface

mapFromScene

public final QPolygonF mapFromScene(QRectF rect)
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.

See also:
mapToScene(), mapFromItem(), transform(), and The Graphics View Coordinate System.

Specified by:
mapFromScene in interface QGraphicsItemInterface

mapFromScene

public final QPointF mapFromScene(double x,
                                  double y)
This convenience function is equivalent to calling mapFromScene(QPointF(x, y)).

Specified by:
mapFromScene in interface QGraphicsItemInterface

mapFromScene

public final QPolygonF mapFromScene(double x,
                                    double y,
                                    double w,
                                    double h)
This convenience function is equivalent to calling mapFromScene(QRectF(x, y, w, h)).

Specified by:
mapFromScene in interface QGraphicsItemInterface

mapToItem

public final QPainterPath mapToItem(QGraphicsItemInterface item,
                                    QPainterPath path)
Maps the path path, which is in this item's coordinate system, to item's coordinate system, and returns the mapped path.

If item is 0, this function returns the same as mapToScene().

See also:
mapToParent(), mapToScene(), mapFromItem(), and The Graphics View Coordinate System.

Specified by:
mapToItem in interface QGraphicsItemInterface

mapToItem

public final QPointF mapToItem(QGraphicsItemInterface item,
                               QPointF point)
Maps the point point, which is in this item's coordinate system, to item's coordinate system, and returns the mapped coordinate.

If item is 0, this function returns the same as mapToScene().

See also:
mapToParent(), mapToScene(), transform(), mapFromItem(), and The Graphics View Coordinate System.

Specified by:
mapToItem in interface QGraphicsItemInterface

mapToItem

public final QPolygonF mapToItem(QGraphicsItemInterface item,
                                 QPolygonF polygon)
Maps the polygon polygon, which is in this item's coordinate system, to item's coordinate system, and returns the mapped polygon.

If item is 0, this function returns the same as mapToScene().

See also:
mapToParent(), mapToScene(), mapFromItem(), and The Graphics View Coordinate System.

Specified by:
mapToItem in interface QGraphicsItemInterface

mapToItem

public final QPolygonF mapToItem(QGraphicsItemInterface item,
                                 QRectF rect)
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.

If item is 0, this function returns the same as mapToScene().

See also:
mapToParent(), mapToScene(), mapFromItem(), and The Graphics View Coordinate System.

Specified by:
mapToItem in interface QGraphicsItemInterface

mapToItem

public final QPointF mapToItem(QGraphicsItemInterface item,
                               double x,
                               double y)
This convenience function is equivalent to calling mapToItem(item, QPointF(x, y)).

Specified by:
mapToItem in interface QGraphicsItemInterface

mapToItem

public final QPolygonF mapToItem(QGraphicsItemInterface item,
                                 double x,
                                 double y,
                                 double w,
                                 double h)
This convenience function is equivalent to calling mapToItem(item, QRectF(x, y, w, h)).

Specified by:
mapToItem in interface QGraphicsItemInterface

mapToParent

public final QPainterPath mapToParent(QPainterPath path)
Maps the path path, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped path. If the item has no parent, path will be mapped to the scene's coordinate system.

See also:
mapToScene(), mapToItem(), mapFromParent(), and The Graphics View Coordinate System.

Specified by:
mapToParent in interface QGraphicsItemInterface

mapToParent

public final QPointF mapToParent(QPointF point)
Maps the point point, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped coordinate. If the item has no parent, point will be mapped to the scene's coordinate system.

See also:
mapToItem(), mapToScene(), transform(), mapFromParent(), and The Graphics View Coordinate System.

Specified by:
mapToParent in interface QGraphicsItemInterface

mapToParent

public final QPolygonF mapToParent(QPolygonF polygon)
Maps the polygon polygon, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped polygon. If the item has no parent, polygon will be mapped to the scene's coordinate system.

See also:
mapToScene(), mapToItem(), mapFromParent(), and The Graphics View Coordinate System.

Specified by:
mapToParent in interface QGraphicsItemInterface

mapToParent

public final QPolygonF mapToParent(QRectF rect)
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. If the item has no parent, rect will be mapped to the scene's coordinate system.

See also:
mapToScene(), mapToItem(), mapFromParent(), and The Graphics View Coordinate System.

Specified by:
mapToParent in interface QGraphicsItemInterface

mapToParent

public final QPointF mapToParent(double x,
                                 double y)
This convenience function is equivalent to calling mapToParent(QPointF(x, y)).

Specified by:
mapToParent in interface QGraphicsItemInterface

mapToParent

public final QPolygonF mapToParent(double x,
                                   double y,
                                   double w,
                                   double h)
This convenience function is equivalent to calling mapToParent(QRectF(x, y, w, h)).

Specified by:
mapToParent in interface QGraphicsItemInterface

mapToScene

public final QPainterPath mapToScene(QPainterPath path)
Maps the path path, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped path.

See also:
mapToParent(), mapToItem(), mapFromScene(), and The Graphics View Coordinate System.

Specified by:
mapToScene in interface QGraphicsItemInterface

mapToScene

public final QPointF mapToScene(QPointF point)
Maps the point point, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped coordinate.

See also:
mapToItem(), mapToParent(), transform(), mapFromScene(), and The Graphics View Coordinate System.

Specified by:
mapToScene in interface QGraphicsItemInterface

mapToScene

public final QPolygonF mapToScene(QPolygonF polygon)
Maps the polygon polygon, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped polygon.

See also:
mapToParent(), mapToItem(), mapFromScene(), and The Graphics View Coordinate System.

Specified by:
mapToScene in interface QGraphicsItemInterface

mapToScene

public final QPolygonF mapToScene(QRectF rect)
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.

See also:
mapToParent(), mapToItem(), mapFromScene(), and The Graphics View Coordinate System.

Specified by:
mapToScene in interface QGraphicsItemInterface

mapToScene

public final QPointF mapToScene(double x,
                                double y)
This convenience function is equivalent to calling mapToScene(QPointF(x, y)).

Specified by:
mapToScene in interface QGraphicsItemInterface

mapToScene

public final QPolygonF mapToScene(double x,
                                  double y,
                                  double w,
                                  double h)
This convenience function is equivalent to calling mapToScene(QRectF(x, y, w, h)).

Specified by:
mapToScene in interface QGraphicsItemInterface

maximumHeight

public final double maximumHeight()
Returns the maximum height.

See also:
setMaximumHeight(), setMaximumSize(), and maximumSize().

Specified by:
maximumHeight in interface QGraphicsLayoutItemInterface

maximumSize

public final QSizeF maximumSize()
Returns the maximum size.

See also:
setMaximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize , and sizeHint().

Specified by:
maximumSize in interface QGraphicsLayoutItemInterface

maximumWidth

public final double maximumWidth()
Returns the maximum width.

See also:
setMaximumWidth(), setMaximumSize(), and maximumSize().

Specified by:
maximumWidth in interface QGraphicsLayoutItemInterface

minimumHeight

public final double minimumHeight()
Returns the minimum height.

See also:
setMinimumHeight(), setMinimumSize(), and minimumSize().

Specified by:
minimumHeight in interface QGraphicsLayoutItemInterface

minimumSize

public final QSizeF minimumSize()
Returns the minimum size.

See also:
setMinimumSize(), preferredSize(), maximumSize(), Qt::MinimumSize , and sizeHint().

Specified by:
minimumSize in interface QGraphicsLayoutItemInterface

minimumWidth

public final double minimumWidth()
Returns the minimum width.

See also:
setMinimumWidth(), setMinimumSize(), and minimumSize().

Specified by:
minimumWidth in interface QGraphicsLayoutItemInterface

moveBy

public final void moveBy(double dx,
                         double dy)
Moves the item by dx points horizontally, and dy point vertically. This function is equivalent to calling setPos(pos() + QPointF(dx, dy)).

Specified by:
moveBy in interface QGraphicsItemInterface

palette

public final QPalette palette()
This property holds the widgets' palette. This property provides the widget's palette. The palette provides colors and brushes for color groups (e.g., QPalette::Button ) and states (e.g., QPalette::Inactive ), loosely defining the general look of the widget and its children.

QPalette consists of color groups that have been explicitly defined, and groups that are implicitly inherited from the widget's parent. Because of this, palette() can return a different palette than what has been set with setPalette(). This scheme allows you to define single entries in a palette without affecting the palette's inherited entries.

When a widget's palette changes, it resolves its entries against its parent widget, or if it doesn't have a parent widget, it resolves against the scene. It then sends itself a PaletteChange event, and notifies all its descendents so they can resolve their palettes as well.

See also:
QApplication::palette(), QGraphicsScene::palette, and QPalette::resolve().


parentItem

public final QGraphicsItemInterface parentItem()
Returns a pointer to this item's parent item. If this item does not have a parent, 0 is returned.

See also:
setParentItem(), and children().

Specified by:
parentItem in interface QGraphicsItemInterface

parentLayoutItem

public final QGraphicsLayoutItemInterface parentLayoutItem()
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes).

See also:
setParentLayoutItem().

Specified by:
parentLayoutItem in interface QGraphicsLayoutItemInterface

parentWidget

public final QGraphicsWidget parentWidget()
Returns a pointer to the item's parent widget. The item's parent widget is the closest parent item that is a widget.

See also:
parentItem(), and childItems().

Specified by:
parentWidget in interface QGraphicsItemInterface

pos

public final QPointF pos()
Returns the position of the item in parent coordinates. If the item has no parent, its position is given in scene coordinates.

The position of the item describes its origin (local coordinate (0, 0)) in parent coordinates; this function returns the same as mapToParent(0, 0).

For convenience, you can also call scenePos() to determine the item's position in scene coordinates, regardless of its parent.

See also:
x(), y(), setPos(), matrix(), and The Graphics View Coordinate System.

Specified by:
pos in interface QGraphicsItemInterface

preferredHeight

public final double preferredHeight()
Returns the preferred height.

See also:
setPreferredHeight(), setPreferredSize(), and preferredSize().

Specified by:
preferredHeight in interface QGraphicsLayoutItemInterface

preferredSize

public final QSizeF preferredSize()
Returns the preferred size.

See also:
setPreferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize , and sizeHint().

Specified by:
preferredSize in interface QGraphicsLayoutItemInterface

preferredWidth

public final double preferredWidth()
Returns the preferred width.

See also:
setPreferredWidth(), setPreferredSize(), and preferredSize().

Specified by:
preferredWidth in interface QGraphicsLayoutItemInterface

prepareGeometryChange

public final void prepareGeometryChange()
Prepares the item for a geometry change. Call this function before changing the bounding rect of an item to keep QGraphicsScene's index up to date.

prepareGeometryChange() will call update() if this is necessary.

Example:

The following code example is written in c++.

        void CircleItem::setRadius(qreal newRadius)
        {
            if (radius != newRadius) {
                prepareGeometryChange();
                radius = newRadius;
            }
        }

See also:
boundingRect().

Specified by:
prepareGeometryChange in interface QGraphicsItemInterface

rect

public final QRectF rect()
Returns the item's local rect as a QRectF. This function is equivalent to QRectF(QPointF(), size()).

See also:
setGeometry(), and resize().


removeFromIndex

public final void removeFromIndex()
This method is internal to Qt Jambi.

Specified by:
removeFromIndex in interface QGraphicsItemInterface

removeSceneEventFilter

public final void removeSceneEventFilter(QGraphicsItemInterface filterItem)
Removes an event filter on this item from filterItem.

See also:
installSceneEventFilter().

Specified by:
removeSceneEventFilter in interface QGraphicsItemInterface

resetTransform

public final void resetTransform()
Resets this item's transformation matrix to the identity matrix. This is equivalent to calling setTransform(QTransform()).

See also:
setTransform(), and transform().

Specified by:
resetTransform in interface QGraphicsItemInterface

resize

public final void resize(QSizeF size)
This property holds the size of the widget. Calling setSize() resizes the widget to size bounded by minimumSize() and maximumSize(). This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.

Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.

This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout, e.g., it has a parent widget with a layout assigned, that layout will not activate.

See also:
setGeometry(), QGraphicsSceneResizeEvent, and QGraphicsLayout.


resize

public final void resize(double w,
                         double h)
This property holds the size of the widget. Calling setSize() resizes the widget to size bounded by minimumSize() and maximumSize(). This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.

Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.

This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout, e.g., it has a parent widget with a layout assigned, that layout will not activate.

See also:
setGeometry(), QGraphicsSceneResizeEvent, and QGraphicsLayout.


rotate

public final void rotate(double angle)
Rotates the current item transformation angle degrees clockwise around its origin. To translate around an arbitrary point (x, y), you need to combine translation and rotation with setTransform().

Example:

The following code example is written in c++.

        // Rotate an item 45 degrees around (0, 0).
        item->rotate(45);

        // Rotate an item 45 degrees around (x, y).
        item->setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y));

See also:
setTransform(), transform(), scale(), shear(), and translate().

Specified by:
rotate in interface QGraphicsItemInterface

scale

public final void scale(double sx,
                        double sy)
Scales the current item transformation by (sx, sy) around its origin. To scale from an arbitrary point (x, y), you need to combine translation and scaling with setTransform().

Example:

The following code example is written in c++.

        // Scale an item by 3x2 from its origin
        item->scale(3, 2);

        // Scale an item by 3x2 from (x, y)
        item->setTransform(QTransform().translate(x, y).scale(3, 2).translate(-x, -y));

See also:
setTransform(), transform(), rotate(), shear(), and translate().

Specified by:
scale in interface QGraphicsItemInterface

scene

public final QGraphicsScene scene()
Returns the current scene for the item, or 0 if the item is not stored in a scene.

To add or move an item to a scene, call QGraphicsScene::addItem().

Specified by:
scene in interface QGraphicsItemInterface

sceneBoundingRect

public final QRectF sceneBoundingRect()
Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect().

See also:
boundingRect(), and The Graphics View Coordinate System.

Specified by:
sceneBoundingRect in interface QGraphicsItemInterface

scenePos

public final QPointF scenePos()
Returns the item's position in scene coordinates. This is equivalent to calling mapToScene(0, 0).

See also:
pos(), sceneTransform(), and The Graphics View Coordinate System.

Specified by:
scenePos in interface QGraphicsItemInterface

sceneTransform

public final QTransform sceneTransform()
Returns this item's scene transformation matrix. This matrix can be used to map coordinates and geometrical shapes from this item's local coordinate system to the scene's coordinate system. To map coordinates from the scene, you must first invert the returned matrix.

Example:

The following code example is written in c++.

        QGraphicsRectItem rect;
        rect.setPos(100, 100);

        rect.sceneTransform().map(QPointF(0, 0));
        // returns QPointF(100, 100);

        rect.sceneTransform().inverted().map(QPointF(100, 100));
        // returns QPointF(0, 0);
Unlike transform(), which returns only an item's local transformation, this function includes the item's (and any parents') position.

See also:
transform(), setTransform(), scenePos(), and The Graphics View Coordinate System.

Specified by:
sceneTransform in interface QGraphicsItemInterface

scroll

public final void scroll(double dx,
                         double dy,
                         QRectF rect)
Scrolls the contents of rect by dx, dy. If rect is a null rect (the default), the item's bounding rect is scrolled.

Scrolling provides a fast alternative to simply redrawing when the contents of the item (or parts of the item) are shifted vertically or horizontally. Depending on the current transformation and the capabilities of the paint device (i.e., the viewport), this operation may consist of simply moving pixels from one location to another using memmove(). In most cases this is faster than rerendering the entire area.

After scrolling, the item will issue an update for the newly exposed areas. If scrolling is not supported (e.g., you are rendering to an OpenGL viewport, which does not benefit from scroll optimizations), this function is equivalent to calling update(rect).

See also:
boundingRect().

Specified by:
scroll in interface QGraphicsItemInterface

setAcceptDrops

public final void setAcceptDrops(boolean on)
If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and drop events. By default, items do not accept drag and drop events.

See also:
acceptDrops().

Specified by:
setAcceptDrops in interface QGraphicsItemInterface

setAcceptHoverEvents

public final void setAcceptHoverEvents(boolean enabled)
If enabled is true, this item will accept hover events; otherwise, it will ignore them. By default, items do not accept hover events.

Hover events are delivered when there is no current mouse grabber item. They are sent when the mouse cursor enters an item, when it moves around inside the item, and when the cursor leaves an item. Hover events are commonly used to highlight an item when it's entered, and for tracking the mouse cursor as it hovers over the item (equivalent to QWidget::mouseTracking).

Parent items receive hover enter events before their children, and leave events after their children. The parent does not receive a hover leave event if the cursor enters a child, though; the parent stays "hovered" until the cursor leaves its area, including its children's areas.

If a parent item handles child events (setHandlesChildEvents()), it will receive hover move, drag move, and drop events as the cursor passes through its children, but it does not receive hover enter and hover leave, nor drag enter and drag leave events on behalf of its children.

A QGraphicsWidget with window decorations will accept hover events regardless of the value of acceptHoverEvents().

See also:
acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent().

Specified by:
setAcceptHoverEvents in interface QGraphicsItemInterface

setAcceptedMouseButtons

public final void setAcceptedMouseButtons(Qt.MouseButtons buttons)
Sets the mouse buttons that this item accepts mouse events for.

By default, all mouse buttons are accepted. If an item accepts a mouse button, it will become the mouse grabber item when a mouse press event is delivered for that button. However, if the item does not accept the mouse button, QGraphicsScene will forward the mouse events to the first item beneath it that does.

To disable mouse events for an item (i.e., make it transparent for mouse events), call setAcceptedMouseButtons(0).

See also:
acceptedMouseButtons(), and mousePressEvent().

Specified by:
setAcceptedMouseButtons in interface QGraphicsItemInterface

setAcceptsHoverEvents

public final void setAcceptsHoverEvents(boolean enabled)
Use setAcceptHoverEvents(enabled) instead.

See also:
acceptsHoverEvents().

Specified by:
setAcceptsHoverEvents in interface QGraphicsItemInterface

setAttribute

public final void setAttribute(Qt.WidgetAttribute attribute)
If on is true, this function enables attribute; otherwise attribute is disabled.

See the class documentation for QGraphicsWidget for a complete list of which attributes are supported, and what they are for.

See also:
testAttribute(), and QWidget::setAttribute().


setAttribute

public final void setAttribute(Qt.WidgetAttribute attribute,
                               boolean on)
If on is true, this function enables attribute; otherwise attribute is disabled.

See the class documentation for QGraphicsWidget for a complete list of which attributes are supported, and what they are for.

See also:
testAttribute(), and QWidget::setAttribute().


setBoundingRegionGranularity

public final void setBoundingRegionGranularity(double granularity)
Sets the bounding region granularity to granularity; a value between and including 0 and 1. The default value is 0 (i.e., the lowest granularity, where the bounding region corresponds to the item's bounding rectangle).

The granularity is used by boundingRegion() to calculate how fine the bounding region of the item should be. The highest achievable granularity is 1, where boundingRegion() will return the finest outline possible for the respective device (e.g., for a QGraphicsView viewport, this gives you a pixel-perfect bounding region). The lowest possible granularity is 0. The value of granularity describes the ratio between device resolution and the resolution of the bounding region (e.g., a value of 0.25 will provide a region where each chunk corresponds to 4x4 device units / pixels).

See also:
boundingRegionGranularity().

Specified by:
setBoundingRegionGranularity in interface QGraphicsItemInterface

setCacheMode

public final void setCacheMode(QGraphicsItem.CacheMode mode,
                               QSize cacheSize)
Sets the item's cache mode to mode.

The optional logicalCacheSize argument is used only by ItemCoordinateCache mode, and describes the resolution of the cache buffer; if logicalCacheSize is (100, 100), QGraphicsItem will fit the item into 100x100 pixels in graphics memory, regardless of the logical size of the item itself. By default QGraphicsItem uses the size of boundingRect(). For all other cache modes than ItemCoordinateCache , logicalCacheSize is ignored.

Caching can speed up rendering if your item spends a significant time redrawing itself. In some cases the cache can also slow down rendering, in particular when the item spends less time redrawing than QGraphicsItem spends redrawing from the cache. When enabled, the item's paint() function will be called only once for each call to update(); for any subsequent repaint requests, the Graphics View framework will redraw from the cache. This approach works particularly well with QGLWidget, which stores all the cache as OpenGL textures.

Be aware that QPixmapCache's cache limit may need to be changed to obtain optimal performance.

You can read more about the different cache modes in the CacheMode documentation.

See also:
cacheMode(), CacheMode , and QPixmapCache::setCacheLimit().

Specified by:
setCacheMode in interface QGraphicsItemInterface

setContentsMargins

public final void setContentsMargins(double left,
                                     double top,
                                     double right,
                                     double bottom)
Sets the widget's contents margins to left, top, right and bottom.

Contents margins are used by the assigned layout to define the placement of subwidgets and layouts. Margins are particularily useful for widgets that constrain subwidgets to only a section of its own geometry. For example, a group box with a layout will place subwidgets inside its frame, but below the title.

Changing a widget's contents margins will always trigger an update(), and any assigned layout will be activated automatically. The widget will then receive a ContentsRectChange event.

See also:
getContentsMargins(), and setGeometry().


setCursor

public final void setCursor(QCursor cursor)
Sets the current cursor shape for the item to cursor. The mouse cursor will assume this shape when it's over this item. See the list of predefined cursor objects for a range of useful shapes.

An editor item might want to use an I-beam cursor:

The following code example is written in c++.

        item->setCursor(Qt::IBeamCursor);
If no cursor has been set, the cursor of the item beneath is used.

See also:
cursor(), hasCursor(), unsetCursor(), QWidget::cursor, and QApplication::overrideCursor().

Specified by:
setCursor in interface QGraphicsItemInterface

setData

public final void setData(int key,
                          java.lang.Object value)
Sets this item's custom data for the key key to value.

Custom item data is useful for storing arbitrary properties for any item. Qt does not use this feature for storing data; it is provided solely for the convenience of the user.

See also:
data().

Specified by:
setData in interface QGraphicsItemInterface

setEnabled

public final void setEnabled(boolean enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.

Disabled items are visible, but they do not receive any events, and cannot take focus nor be selected. Mouse events are discarded; they are not propagated unless the item is also invisible, or if it does not accept mouse events (see acceptedMouseButtons()). A disabled item cannot become the mouse grabber, and as a result of this, an item loses the grab if it becomes disabled when grabbing the mouse, just like it loses focus if it had focus when it was disabled.

Disabled items are traditionally drawn using grayed-out colors (see QPalette::Disabled ).

If you disable a parent item, all its children will also be disabled. If you enable a parent item, all children will be enabled, unless they have been explicitly disabled (i.e., if you call setEnabled(false) on a child, it will not be reenabled if its parent is disabled, and then enabled again).

Items are enabled by default.

Note: If you install an event filter, you can still intercept events before they are delivered to items; this mechanism disregards the item's enabled state.

See also:
isEnabled().

Specified by:
setEnabled in interface QGraphicsItemInterface

setFlag

public final void setFlag(QGraphicsItem.GraphicsItemFlag flag,
                          boolean enabled)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.

See also:
flags(), and setFlags().

Specified by:
setFlag in interface QGraphicsItemInterface

setFlags

public final void setFlags(QGraphicsItem.GraphicsItemFlags flags)
Sets the item flags to flags. All flags in flags are enabled; all flags not in flags are disabled.

If the item had focus and flags does not enable ItemIsFocusable , the item loses focus as a result of calling this function. Similarly, if the item was selected, and flags does not enabled ItemIsSelectable , the item is automatically unselected.

By default, no flags are enabled.

See also:
flags(), and setFlag().

Specified by:
setFlags in interface QGraphicsItemInterface

setFocus

public final void setFocus(Qt.FocusReason focusReason)
Gives keyboard input focus to this item. The focusReason argument will be passed into any focus event generated by this function; it is used to give an explanation of what caused the item to get focus.

Only items that set the ItemIsFocusable flag can accept keyboard focus.

If this item is not visible (i.e., isVisible() returns false), not enabled, not associated with a scene, or if it already has input focus, this function will do nothing.

As a result of calling this function, this item will receive a focus in event with focusReason. If another item already has focus, that item will first receive a focus out event indicating that it has lost input focus.

See also:
clearFocus(), and hasFocus().

Specified by:
setFocus in interface QGraphicsItemInterface

setFocusPolicy

public final void setFocusPolicy(Qt.FocusPolicy policy)
This property holds the way the widget accepts keyboard focus. The focus policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it does not accept focus at all.

You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus ).

If you enable a focus policy (i.e., not Qt::NoFocus ), QGraphicsWidget will automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a widget will clear the ItemIsFocusable flag. If the widget currently has keyboard focus, the widget will automatically lose focus.

See also:
focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), and enabled.


setFont

public final void setFont(QFont font)
This property holds the widgets' font. This property provides the widget's font.

QFont consists of font properties that have been explicitly defined and properties implicitly inherited from the widget's parent. Hence, font() can return a different font compared to the one set with setFont(). This scheme allows you to define single entries in a font without affecting the font's inherited entries.

When a widget's font changes, it resolves its entries against its parent widget. If the widget does not have a parent widget, it resolves its entries against the scene. The widget then sends itself a FontChange event and notifies all its descendants so that they can resolve their fonts as well.

See also:
QApplication::font(), QGraphicsScene::font, and QFont::resolve().


setGeometry

public final void setGeometry(double x,
                              double y,
                              double w,
                              double h)
This convenience function is equivalent to calling setGeometry(QRectF( x, y, w, h)).

See also:
geometry(), and resize().


setGroup

public final void setGroup(QGraphicsItemGroup group)
Adds this item to the item group group. If group is 0, this item is removed from any current group and added as a child of the previous group's parent.

See also:
group(), and QGraphicsScene::createItemGroup().

Specified by:
setGroup in interface QGraphicsItemInterface

setHandlesChildEvents

public final void setHandlesChildEvents(boolean enabled)
If enabled is true, this item is set to handle all events for all its children (i.e., all events intented for any of its children are instead sent to this item); otherwise, if enabled is false, this item will only handle its own events. The default value is false.

This property is useful for item groups; it allows one item to handle events on behalf of its children, as opposed to its children handling their events individually.

If a child item accepts hover events, its parent will receive hover move events as the cursor passes through the child, but it does not receive hover enter and hover leave events on behalf of its child.

See also:
handlesChildEvents().

Specified by:
setHandlesChildEvents in interface QGraphicsItemInterface

setLayout

public final void setLayout(QGraphicsLayout layout)
Sets the layout for this widget to layout. Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.

All widgets that are currently managed by layout or all of its sublayouts, are automatically reparented to this item. The layout is then invalidated, and the child widget geometries are adjusted according to this item's geometry() and contentsMargins(). Children who are not explicitly managed by layout remain unaffected by the layout after it has been assigned to this widget.

QGraphicsWidget takes ownership of layout.

See also:
layout(), QGraphicsLinearLayout::addItem(), and QGraphicsLayout::invalidate().


setLayoutDirection

public final void setLayoutDirection(Qt.LayoutDirection direction)
This property holds the layout direction for this widget.. This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.

The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt::LeftToRight , the layout starts placing subwidgets from the left side of this widget towards the right. Qt::RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.

Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling setLayoutDirection(), the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.

See also:
QWidget::layoutDirection, and QApplication::layoutDirection.


setMaximumHeight

public final void setMaximumHeight(double height)
Sets the maximum height to height.

See also:
maximumHeight(), setMaximumSize(), and maximumSize().

Specified by:
setMaximumHeight in interface QGraphicsLayoutItemInterface

setMaximumSize

public final void setMaximumSize(QSizeF size)
Sets the maximum size to size. This property overrides sizeHint() for Qt::MaximumSize and ensures that effectiveSizeHint() will never return a size larger than size. In order to unset the maximum size, use an invalid size.

See also:
maximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize , and sizeHint().

Specified by:
setMaximumSize in interface QGraphicsLayoutItemInterface

setMaximumSize

public final void setMaximumSize(double w,
                                 double h)
This convenience function is equivalent to calling setMaximumSize(QSizeF(w, h)).

See also:
maximumSize(), setMinimumSize(), setPreferredSize(), and sizeHint().

Specified by:
setMaximumSize in interface QGraphicsLayoutItemInterface

setMaximumWidth

public final void setMaximumWidth(double width)
Sets the maximum width to width.

See also:
maximumWidth(), setMaximumSize(), and maximumSize().

Specified by:
setMaximumWidth in interface QGraphicsLayoutItemInterface

setMinimumHeight

public final void setMinimumHeight(double height)
Sets the minimum height to height.

See also:
minimumHeight(), setMinimumSize(), and minimumSize().

Specified by:
setMinimumHeight in interface QGraphicsLayoutItemInterface

setMinimumSize

public final void setMinimumSize(QSizeF size)
Sets the minimum size to size. This property overrides sizeHint() for Qt::MinimumSize and ensures that effectiveSizeHint() will never return a size smaller than size. In order to unset the minimum size, use an invalid size.

See also:
minimumSize(), maximumSize(), preferredSize(), Qt::MinimumSize , sizeHint(), setMinimumWidth(), and setMinimumHeight().

Specified by:
setMinimumSize in interface QGraphicsLayoutItemInterface

setMinimumSize

public final void setMinimumSize(double w,
                                 double h)
This convenience function is equivalent to calling setMinimumSize(QSizeF(w, h)).

See also:
minimumSize(), setMaximumSize(), setPreferredSize(), and sizeHint().

Specified by:
setMinimumSize in interface QGraphicsLayoutItemInterface

setMinimumWidth

public final void setMinimumWidth(double width)
Sets the minimum width to width.

See also:
minimumWidth(), setMinimumSize(), and minimumSize().

Specified by:
setMinimumWidth in interface QGraphicsLayoutItemInterface

setPalette

public final void setPalette(QPalette palette)
This property holds the widgets' palette. This property provides the widget's palette. The palette provides colors and brushes for color groups (e.g., QPalette::Button ) and states (e.g., QPalette::Inactive ), loosely defining the general look of the widget and its children.

QPalette consists of color groups that have been explicitly defined, and groups that are implicitly inherited from the widget's parent. Because of this, palette() can return a different palette than what has been set with setPalette(). This scheme allows you to define single entries in a palette without affecting the palette's inherited entries.

When a widget's palette changes, it resolves its entries against its parent widget, or if it doesn't have a parent widget, it resolves against the scene. It then sends itself a PaletteChange event, and notifies all its descendents so they can resolve their palettes as well.

See also:
QApplication::palette(), QGraphicsScene::palette, and QPalette::resolve().


setParentItem

public final void setParentItem(QGraphicsItemInterface parent)
Sets this item's parent item to parent. If this item already has a parent, it is first removed from the previous parent. If parent is 0, this item will become a top-level item.

See also:
parentItem(), and children().

Specified by:
setParentItem in interface QGraphicsItemInterface

setParentLayoutItem

public final void setParentLayoutItem(QGraphicsLayoutItemInterface parent)
Sets the parent of this QGraphicsLayoutItem to parent.

See also:
parentLayoutItem().

Specified by:
setParentLayoutItem in interface QGraphicsLayoutItemInterface

setPos

public final void setPos(QPointF pos)
Sets the position of the item to pos, which is in parent coordinates. For items with no parent, pos is in scene coordinates.

The position of the item describes its origin (local coordinate (0, 0)) in parent coordinates.

See also:
pos(), scenePos(), and The Graphics View Coordinate System.

Specified by:
setPos in interface QGraphicsItemInterface

setPos

public final void setPos(double x,
                         double y)
This convenience function is equivalent to calling setPos(QPointF(x, y)).

Specified by:
setPos in interface QGraphicsItemInterface

setPreferredHeight

public final void setPreferredHeight(double height)
Sets the preferred height to height.

See also:
preferredHeight(), preferredWidth(), setPreferredSize(), and preferredSize().

Specified by:
setPreferredHeight in interface QGraphicsLayoutItemInterface

setPreferredSize

public final void setPreferredSize(QSizeF size)
Sets the preferred size to size. This property overrides sizeHint() for Qt::PreferredSize and provides the default value for effectiveSizeHint(). In order to unset the preferred size, use an invalid size.

See also:
preferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize , and sizeHint().

Specified by:
setPreferredSize in interface QGraphicsLayoutItemInterface

setPreferredSize

public final void setPreferredSize(double w,
                                   double h)
This convenience function is equivalent to calling setPreferredSize(QSizeF(w, h)).

See also:
preferredSize(), setMaximumSize(), setMinimumSize(), and sizeHint().

Specified by:
setPreferredSize in interface QGraphicsLayoutItemInterface

setPreferredWidth

public final void setPreferredWidth(double width)
Sets the preferred width to width.

See also:
preferredWidth(), preferredHeight(), setPreferredSize(), and preferredSize().

Specified by:
setPreferredWidth in interface QGraphicsLayoutItemInterface

setSelected

public final void setSelected(boolean selected)
If selected is true and this item is selectable, this item is selected; otherwise, it is unselected.

If the item is in a group, the whole group's selected state is toggled by this function. If the group is selected, all items in the group are also selected, and if the group is not selected, no item in the group is selected.

Only visible, enabled, selectable items can be selected. If selected is true and this item is either invisible or disabled or unselectable, this function does nothing.

By default, items cannot be selected. To enable selection, set the ItemIsSelectable flag.

This function is provided for convenience, allowing individual toggling of the selected state of an item. However, a more common way of selecting items is to call QGraphicsScene::setSelectionArea(), which will call this function for all visible, enabled, and selectable items within a specified area on the scene.

See also:
isSelected(), and QGraphicsScene::selectedItems().

Specified by:
setSelected in interface QGraphicsItemInterface

setSizePolicy

public final void setSizePolicy(QSizePolicy.Policy hPolicy,
                                QSizePolicy.Policy vPolicy,
                                QSizePolicy.ControlType controlType)
This function is equivalent to calling setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)).

See also:
sizePolicy(), and QWidget::sizePolicy().

Specified by:
setSizePolicy in interface QGraphicsLayoutItemInterface

setSizePolicy

public final void setSizePolicy(QSizePolicy policy)
Sets the size policy to policy. The size policy describes how the item should grow horizontally and vertically when arranged in a layout.

QGraphicsLayoutItem's default size policy is (QSizePolicy::Fixed , QSizePolicy::Fixed , QSizePolicy::DefaultType ), but it is common for subclasses to change the default. For example, QGraphicsWidget defaults to (QSizePolicy::Preferred , QSizePolicy::Preferred , QSizePolicy::DefaultType ).

See also:
sizePolicy(), and QWidget::sizePolicy().

Specified by:
setSizePolicy in interface QGraphicsLayoutItemInterface

setStyle

public final void setStyle(QStyle style)
Sets the widget's style to style. QGraphicsWidget does not take ownership of style.

If no style is assigned, or style is 0, the widget will use QGraphicsScene::style() (if this has been set). Otherwise the widget will use QApplication::style().

This function sets the Qt::WA_SetStyle attribute if style is not 0; otherwise it clears the attribute.

See also:
style().


setToolTip

public final void setToolTip(java.lang.String toolTip)
Sets the item's tool tip to toolTip. If toolTip is empty, the item's tool tip is cleared.

See also:
toolTip(), and QToolTip.

Specified by:
setToolTip in interface QGraphicsItemInterface

setTransform

public final void setTransform(QTransform matrix,
                               boolean combine)
Sets the item's current transformation matrix to matrix.

If combine is true, then matrix is combined with the current matrix; otherwise, matrixreplaces the current matrix. combine is false by default.

To simplify interation with items using a transformed view, QGraphicsItem provides mapTo... and mapFrom... functions that can translate between items' and the scene's coordinates. For example, you can call mapToScene() to map an item coordiate to a scene coordinate, or mapFromScene() to map from scene coordinates to item coordinates.

See also:
transform(), rotate(), scale(), shear(), translate(), and The Graphics View Coordinate System.

Specified by:
setTransform in interface QGraphicsItemInterface

setVisible

public final void setVisible(boolean visible)
If visible is true, the item is made visible. Otherwise, the item is made invisible. Invisible items are not painted, nor do they receive any events. In particular, mouse events pass right through invisible items, and are delivered to any item that may be behind. Invisible items are also unselectable, they cannot take input focus, and are not detected by QGraphicsScene's item location functions.

If an item becomes invisible while grabbing the mouse, (i.e., while it is receiving mouse events,) it will automatically lose the mouse grab, and the grab is not regained by making the item visible again; it must receive a new mouse press to regain the mouse grab.

Similarly, an invisible item cannot have focus, so if the item has focus when it becomes invisible, it will lose focus, and the focus is not regained by simply making the item visible again.

If you hide a parent item, all its children will also be hidden. If you show a parent item, all children will be shown, unless they have been explicitly hidden (i.e., if you call setVisible(false) on a child, it will not be reshown even if its parent is hidden, and then shown again).

Items are visible by default; it is unnecessary to call setVisible() on a new item.

See also:
isVisible(), show(), and hide().

Specified by:
setVisible in interface QGraphicsItemInterface

setWindowFlags

public final void setWindowFlags(Qt.WindowType... wFlags)
This property holds This propery holds the widget's window flags.. Window flags are a combination a window type (e.g. Qt::Dialog ) and several flags giving hints on the behaviour of the window. The behaviour is platform dependent.


setWindowFlags

public final void setWindowFlags(Qt.WindowFlags wFlags)
This property holds This propery holds the widget's window flags.. Window flags are a combination a window type (e.g. Qt::Dialog ) and several flags giving hints on the behaviour of the window. The behaviour is platform dependent.


setWindowFrameMargins

public final void setWindowFrameMargins(double left,
                                        double top,
                                        double right,
                                        double bottom)
Sets the widget's window frame margins to left, top, right and bottom. The default frame margins are provided by the style, and they depend on the current window flags.

If you would like to draw your own window decoration, you can set your own frame margins to override the default margins.

See also:
unsetWindowFrameMargins(), getWindowFrameMargins(), and windowFrameRect().


setWindowTitle

public final void setWindowTitle(java.lang.String title)
This property holds This property holds the window title (caption).. This property is only used for windows. If no title has been set, the title is an empty string.


setZValue

public final void setZValue(double z)
Sets the Z-value, or the elevation, of the item, to z. The elevation decides the stacking order of sibling (neighboring) items. An item of high Z-value will be drawn on top of an item with a lower Z-value if they share the same parent item. In addition, children of an item will always be drawn on top of the parent, regardless of the child's Z-value. Sibling items that share the same Z-value will be drawn in an undefined order, although the order will stay the same for as long as the items live.

Children of different parents are stacked according to the Z-value of each item's ancestor item which is an immediate child of the two items' closest common ancestor. For example, a robot item might define a torso item as the parent of a head item, two arm items, and two upper-leg items. The upper-leg items would each be parents of one lower-leg item, and each lower-leg item would be parents of one foot item. The stacking order of the feet is the same as the stacking order of each foot's ancestor that is an immediate child of the two feet's common ancestor (i.e., the torso item); so the feet are stacked in the same order as the upper-leg items, regardless of each foot's Z-value.

The Z-value does not affect the item's size in any way.

The default Z-value is 0.

See also:
zValue().

Specified by:
setZValue in interface QGraphicsItemInterface

shear

public final void shear(double sh,
                        double sv)
Shears the current item transformation by (sh, sv).

See also:
setTransform(), transform(), rotate(), scale(), and translate().

Specified by:
shear in interface QGraphicsItemInterface

show

public final void show()
Shows the item. (Items are visible by default.)

This convenience function is equivalent to calling setVisible(true).

See also:
hide(), and setVisible().

Specified by:
show in interface QGraphicsItemInterface

size

public final QSizeF size()
This property holds the size of the widget. Calling setSize() resizes the widget to size bounded by minimumSize() and maximumSize(). This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.

Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.

This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout, e.g., it has a parent widget with a layout assigned, that layout will not activate.

See also:
setGeometry(), QGraphicsSceneResizeEvent, and QGraphicsLayout.


sizePolicy

public final QSizePolicy sizePolicy()
Returns the current size policy.

See also:
setSizePolicy(), and QWidget::sizePolicy().

Specified by:
sizePolicy in interface QGraphicsLayoutItemInterface

style

public final QStyle style()
Returns a pointer to the widget's style. If this widget does not have any explicitly assigned style, the scene's style is returned instead. In turn, if the scene does not have any assigned style, this function returns QApplication::style().

See also:
setStyle().


testAttribute

public final boolean testAttribute(Qt.WidgetAttribute attribute)
Returns true if attribute is enabled for this widget; otherwise, returns false.

See also:
setAttribute().


toolTip

public final java.lang.String toolTip()
Returns the item's tool tip, or an empty QString if no tool tip has been set.

See also:
setToolTip(), and QToolTip.

Specified by:
toolTip in interface QGraphicsItemInterface

topLevelItem

public final QGraphicsItemInterface topLevelItem()
Returns this item's top-level item. The top-level item is the item's topmost ancestor item whose parent is 0. If an item has no parent, its own pointer is returned (i.e., a top-level item is its own top-level item).

See also:
parentItem().

Specified by:
topLevelItem in interface QGraphicsItemInterface

topLevelWidget

public final QGraphicsWidget topLevelWidget()
Returns a pointer to the item's top level widget (i.e., the item's ancestor whose parent is 0, or whose parent is not a widget), or 0 if this item does not have a top level widget. If the item is its own top level widget, this function returns a pointer to the item itself.

Specified by:
topLevelWidget in interface QGraphicsItemInterface

transform

public final QTransform transform()
Returns this item's transformation matrix. If no matrix has been set, the identity matrix is returned.

See also:
setTransform(), and sceneTransform().

Specified by:
transform in interface QGraphicsItemInterface

translate

public final void translate(double dx,
                            double dy)
Translates the current item transformation by (dx, dy).

If all you want is to move an item, you should call moveBy() or setPos() instead; this function changes the item's translation, which is conceptually separate from its position.

See also:
setTransform(), transform(), rotate(), scale(), and shear().

Specified by:
translate in interface QGraphicsItemInterface

ungrabKeyboard

public final void ungrabKeyboard()
Releases the keyboard grab.

See also:
grabKeyboard(), and ungrabMouse().

Specified by:
ungrabKeyboard in interface QGraphicsItemInterface

ungrabMouse

public final void ungrabMouse()
Releases the mouse grab.

See also:
grabMouse(), and ungrabKeyboard().

Specified by:
ungrabMouse in interface QGraphicsItemInterface

unsetCursor

public final void unsetCursor()
Clears the cursor from this item.

See also:
hasCursor(), and setCursor().

Specified by:
unsetCursor in interface QGraphicsItemInterface

unsetLayoutDirection

public final void unsetLayoutDirection()
This property holds the layout direction for this widget.. This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.

The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt::LeftToRight , the layout starts placing subwidgets from the left side of this widget towards the right. Qt::RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.

Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling setLayoutDirection(), the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.

See also:
QWidget::layoutDirection, and QApplication::layoutDirection.


unsetWindowFrameMargins

public final void unsetWindowFrameMargins()
Resets the window frame margins to the default value, provided by the style.

See also:
setWindowFrameMargins(), getWindowFrameMargins(), and windowFrameRect().


update

public final void update(QRectF rect)
Schedules a redraw of the area covered by rect in this item. You can call this function whenever your item needs to be redrawn, such as if it changes appearance or size.

This function does not cause an immediate paint; instead it schedules a paint request that is processed by QGraphicsView after control reaches the event loop. The item will only be redrawn if it is visible in any associated view.

As a side effect of the item being repainted, other items that overlap the area rect may also be repainted.

If the item is invisible (i.e., isVisible() returns false), this function does nothing.

See also:
paint(), and boundingRect().

Specified by:
update in interface QGraphicsItemInterface

update

public final void update(double x,
                         double y,
                         double width,
                         double height)
This convenience function is equivalent to calling update(QRectF(x, y, width, height)).

Specified by:
update in interface QGraphicsItemInterface

window

public final QGraphicsWidget window()
Returns the item's window, or 0 if this item does not have a window. If the item is a window, it will return itself. Otherwise it will return the closest ancestor that is a window.

See also:
QGraphicsWidget::isWindow().

Specified by:
window in interface QGraphicsItemInterface

windowFlags

public final Qt.WindowFlags windowFlags()
This property holds This propery holds the widget's window flags.. Window flags are a combination a window type (e.g. Qt::Dialog ) and several flags giving hints on the behaviour of the window. The behaviour is platform dependent.


windowFrameGeometry

public final QRectF windowFrameGeometry()
Returns the widget's geometry in parent coordinates including any window frame.

See also:
windowFrameRect(), getWindowFrameMargins(), and setWindowFrameMargins().


windowFrameRect

public final QRectF windowFrameRect()
Returns the widget's local rect including any window frame.

See also:
windowFrameGeometry(), getWindowFrameMargins(), and setWindowFrameMargins().


windowTitle

public final java.lang.String windowTitle()
This property holds This property holds the window title (caption).. This property is only used for windows. If no title has been set, the title is an empty string.


windowType

public final Qt.WindowType windowType()
Returns the widgets window type.


x

public final double x()
This convenience function is equivalent to calling pos().x().

See also:
y().

Specified by:
x in interface QGraphicsItemInterface

y

public final double y()
This convenience function is equivalent to calling pos().y().

See also:
x().

Specified by:
y in interface QGraphicsItemInterface

zValue

public final double zValue()
Returns the Z-value, or the elevation, of the item. The Z-value decides the stacking order of sibling (neighboring) items.

The default Z-value is 0.

See also:
setZValue().

Specified by:
zValue in interface QGraphicsItemInterface

advance

public void advance(int phase)
This virtual function is called twice for all items by the QGraphicsScene::advance() slot. In the first phase, all items are called with phase == 0, indicating that items on the scene are about to advance, and then all items are called with phase == 1. Reimplement this function to update your item if you need simple scene-controlled animation.

The default implementation does nothing.

For individual item animation, an alternative to this function is to either use QGraphicsItemAnimation, or to multiple-inherit from QObject and QGraphicsItem, and animate your item using QObject::startTimer() and QObject::timerEvent().

See also:
QGraphicsItemAnimation, and QTimeLine.

Specified by:
advance in interface QGraphicsItemInterface

boundingRect

public QRectF boundingRect()
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be restricted to inside an item's bounding rect. QGraphicsView uses this to determine whether the item requires redrawing.

Although the item's shape can be arbitrary, the bounding rect is always rectangular, and it is unaffected by the items' transformation (scale(), rotate(), etc.).

If you want to change the item's bounding rectangle, you must first call prepareGeometryChange(). This notifies the scene of the imminent change, so that its can update its item geometry index; otherwise, the scene will be unaware of the item's new geometry, and the results are undefined (typically, rendering artifacts are left around in the view).

Reimplement this function to let QGraphicsView determine what parts of the widget, if any, need to be redrawn.

Note: For shapes that paint an outline / stroke, it is important to include half the pen width in the bounding rect. It is not necessary to compensate for antialiasing, though.

Example:

The following code example is written in c++.

    QRectF CircleItem::boundingRect() const
    {
        qreal penWidth = 1;
        return QRectF(-radius - penWidth / 2, -radius - penWidth / 2,
                      diameter + penWidth, diameter + penWidth);
    }

See also:
boundingRegion(), shape(), contains(), The Graphics View Coordinate System, and prepareGeometryChange().

Specified by:
boundingRect in interface QGraphicsItemInterface

changeEvent

protected void changeEvent(QEvent event)
This event handler can be reimplemented to handle state changes.

The state being changed in this event can be retrieved through event.

Change events include: QEvent::ActivationChange , QEvent::EnabledChange , QEvent::FontChange , QEvent::StyleChange , QEvent::PaletteChange , QEvent::ParentChange , QEvent::LayoutDirectionChange , and QEvent::ContentsRectChange .


closeEvent

protected void closeEvent(QCloseEvent event)
This event handler, for event, can be reimplemented in a subclass to receive widget close events. The default implementation accepts the event.

See also:
close(), and QCloseEvent.


collidesWithItem

public boolean collidesWithItem(QGraphicsItemInterface other,
                                Qt.ItemSelectionMode mode)
Returns true if this item collides with other; otherwise returns false. The ways items collide is determined by mode. The default value for mode is Qt::IntersectsItemShape ; other collides with this item if it either intersects, contains, or is contained by this item's shape.

The default implementation is based on shape intersection, and it calls shape() on both items. Because the complexity of arbitrary shape-shape intersection grows with an order of magnitude when the shapes are complex, this operation can be noticably time consuming. You have the option of reimplementing this function in a subclass of QGraphicsItem to provide a custom algorithm. This allows you to make use of natural constraints in the shapes of your own items, in order to improve the performance of the collision detection. For instance, two untransformed perfectly circular items' collision can be determined very efficiently by comparing their positions and radii.

Keep in mind that when reimplementing this function and calling shape() or boundingRect() on other, the returned coordinates must be mapped to this item's coordinate system before any intersection can take place.

See also:
contains(), and shape().

Specified by:
collidesWithItem in interface QGraphicsItemInterface

collidesWithPath

public boolean collidesWithPath(QPainterPath path,
                                Qt.ItemSelectionMode mode)
Returns true if this item collides with path.

The collision is determined by mode. The default value for mode is Qt::IntersectsItemShape ; path collides with this item if it either intersects, contains, or is contained by this item's shape.

See also:
collidesWithItem(), contains(), and shape().

Specified by:
collidesWithPath in interface QGraphicsItemInterface

contains

public boolean contains(QPointF point)
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned. It is most often called from QGraphicsView to determine what item is under the cursor, and for that reason, the implementation of this function should be as light-weight as possible.

By default, this function calls shape(), but you can reimplement it in a subclass to provide a (perhaps more efficient) implementation.

See also:
shape(), boundingRect(), and collidesWithPath().

Specified by:
contains in interface QGraphicsItemInterface

contextMenuEvent

public void contextMenuEvent(QGraphicsSceneContextMenuEvent event)
This event handler can be reimplemented in a subclass to process context menu events. The event parameter contains details about the event to be handled.

If you ignore the event, (i.e., by calling QEvent::ignore(),) event will propagate to any item beneath this item. If no items accept the event, it will be ignored by the scene, and propagate to the view.

It's common to open a QMenu in response to receiving a context menu event. Example:

The following code example is written in c++.

        void CustomItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
        {
            QMenu menu;
            QAction *removeAction = menu.addAction("Remove");
            QAction *markAction = menu.addAction("Mark");
            QAction *selectedAction = menu.exec(event->screenPos());
            // ...
        }
The default implementation ignores the event.

See also:
sceneEvent().

Specified by:
contextMenuEvent in interface QGraphicsItemInterface

dragEnterEvent

public void dragEnterEvent(QGraphicsSceneDragDropEvent event)
This event handler, for event event, can be reimplemented to receive drag enter events for this item. Drag enter events are generated as the cursor enters the item's area.

By accepting the event, (i.e., by calling QEvent::accept(),) the item will accept drop events, in addition to receiving drag move and drag leave. Otherwise, the event will be ignored and propagate to the item beneath. If the event is accepted, the item will receive a drag move event before control goes back to the event loop.

A common implementation of dragEnterEvent accepts or ignores event depending on the associated mime data in event. Example:

The following code example is written in c++.

        CustomItem::CustomItem()
        {
            setAcceptDrops(true);
            ...
        }

        void CustomItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
        {
            event->setAccepted(event->mimeData()->hasFormat("text/plain"));
        }
Items do not receive drag and drop events by default; to enable this feature, call setAcceptDrops(true).

The default implementation does nothing.

See also:
dropEvent(), dragMoveEvent(), and dragLeaveEvent().

Specified by:
dragEnterEvent in interface QGraphicsItemInterface

dragLeaveEvent

public void dragLeaveEvent(QGraphicsSceneDragDropEvent event)
This event handler, for event event, can be reimplemented to receive drag leave events for this item. Drag leave events are generated as the cursor leaves the item's area. Most often you will not need to reimplement this function, but it can be useful for resetting state in your item (e.g., highlighting).

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

Items do not receive drag and drop events by default; to enable this feature, call setAcceptDrops(true).

The default implementation does nothing.

See also:
dragEnterEvent(), dropEvent(), and dragMoveEvent().

Specified by:
dragLeaveEvent in interface QGraphicsItemInterface

dragMoveEvent

public void dragMoveEvent(QGraphicsSceneDragDropEvent event)
This event handler, for event event, can be reimplemented to receive drag move events for this item. Drag move events are generated as the cursor moves around inside the item's area. Most often you will not need to reimplement this function; it is used to indicate that only parts of the item can accept drops.

Calling QEvent::ignore() or QEvent::accept() on event toggles whether or not the item will accept drops at the position from the event. By default, event is accepted, indicating that the item allows drops at the specified position.

Items do not receive drag and drop events by default; to enable this feature, call setAcceptDrops(true).

The default implementation does nothing.

See also:
dropEvent(), dragEnterEvent(), and dragLeaveEvent().

Specified by:
dragMoveEvent in interface QGraphicsItemInterface

dropEvent

public void dropEvent(QGraphicsSceneDragDropEvent event)
This event handler, for event event, can be reimplemented to receive drop events for this item. Items can only receive drop events if the last drag move event was accepted.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

Items do not receive drag and drop events by default; to enable this feature, call setAcceptDrops(true).

The default implementation does nothing.

See also:
dragEnterEvent(), dragMoveEvent(), and dragLeaveEvent().

Specified by:
dropEvent in interface QGraphicsItemInterface

event

public boolean event(QEvent event)
This method is reimplemented for internal reasons.

Overrides:
event in class QObject

extension

public java.lang.Object extension(java.lang.Object variant)
This method is internal to Qt Jambi.

Specified by:
extension in interface QGraphicsItemInterface

focusInEvent

public void focusInEvent(QFocusEvent event)
This event handler, for event event, can be reimplemented to receive focus in events for this item. The default implementation calls ensureVisible().

See also:
focusOutEvent(), and sceneEvent().

Specified by:
focusInEvent in interface QGraphicsItemInterface

focusNextPrevChild

protected boolean focusNextPrevChild(boolean next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget; returns false otherwise. If next is true, this function searches forward; if next is false, it searches backward.

Sometimes, you will want to reimplement this function to provide special focus handling for your widget and its subwidgets. For example, a web browser might reimplement it to move its current active link forward or backward, and call the base implementation only when it reaches the last or first link on the page.

Child widgets call focusNextPrevChild() on their parent widgets, but only the window that contains the child widgets decides where to redirect focus. By reimplementing this function for an object, you gain control of focus traversal for all child widgets.

See also:
focusPolicy().


focusOutEvent

public void focusOutEvent(QFocusEvent event)
This event handler, for event event, can be reimplemented to receive focus out events for this item. The default implementation does nothing.

See also:
focusInEvent(), and sceneEvent().

Specified by:
focusOutEvent in interface QGraphicsItemInterface

grabKeyboardEvent

protected void grabKeyboardEvent(QEvent event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::GrabKeyboard events.

See also:
grabKeyboard(), and grabMouse().


grabMouseEvent

protected void grabMouseEvent(QEvent event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::GrabMouse events.

See also:
grabMouse(), and grabKeyboard().


hideEvent

protected void hideEvent(QHideEvent event)
This event handler, for Hide events, is delivered after the widget has been hidden, for example, setVisible(false) has been called for the widget or one of its ancestors when the widget was previously shown.

You can reimplement this event handler to detect when your widget is hidden. Calling QEvent::accept() or QEvent::ignore() on event has no effect.

See also:
showEvent(), QWidget::hideEvent(), and ItemVisibleChange .


hoverEnterEvent

public void hoverEnterEvent(QGraphicsSceneHoverEvent event)
This event handler, for event event, can be reimplemented to receive hover enter events for this item. The default implementation calls update(); otherwise it does nothing.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

See also:
hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), and setAcceptHoverEvents().

Specified by:
hoverEnterEvent in interface QGraphicsItemInterface

hoverLeaveEvent

public void hoverLeaveEvent(QGraphicsSceneHoverEvent event)
This event handler, for event event, can be reimplemented to receive hover leave events for this item. The default implementation calls update(); otherwise it does nothing.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

See also:
hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), and setAcceptHoverEvents().

Specified by:
hoverLeaveEvent in interface QGraphicsItemInterface

hoverMoveEvent

public void hoverMoveEvent(QGraphicsSceneHoverEvent event)
This event handler, for event event, can be reimplemented to receive hover move events for this item. The default implementation does nothing.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

See also:
hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), and setAcceptHoverEvents().

Specified by:
hoverMoveEvent in interface QGraphicsItemInterface

initStyleOption

protected void initStyleOption(QStyleOption option)
Populates a style option object for this widget based on its current state, and stores the output in option. The default implementation populates option with the following properties.
state & QStyle::State_Enabled Corresponds to QGraphicsItem::isEnabled().
state & QStyle::State_HasFocus Corresponds to QGraphicsItem::hasFocus().
state & QStyle::State_MouseOver Corresponds to QGraphicsItem::isUnderMouse().
direction Corresponds to QGraphicsWidget::layoutDirection().
rect Corresponds to QGraphicsWidget::rect().toRect().
palette Corresponds to QGraphicsWidget::palette().
fontMetrics Corresponds to QFontMetrics(QGraphicsWidget::font()).
Subclasses of QGraphicsWidget should call the base implementation, and then test the type of option using qstyleoption_cast<>() or test QStyleOption::Type before storing widget-specific options.

For example:

The following code example is written in c++.

        void MyGroupBoxWidget::initStyleOption(QStyleOption *option) const
        {
            QGraphicsWidget::initStyleOption(option);
            if (QStyleOptionGroupBox *box = qstyleoption_cast<QStyleOptionGroupBox *>(option)) {
                // Add group box specific state.
                box->flat = isFlat();
                ...
            }
        }

See also:
QStyleOption::initFrom().


inputMethodEvent

public void inputMethodEvent(QInputMethodEvent event)
This event handler, for event event, can be reimplemented to receive input method events for this item. The default implementation ignores the event.

See also:
inputMethodQuery(), and sceneEvent().

Specified by:
inputMethodEvent in interface QGraphicsItemInterface

inputMethodQuery

public java.lang.Object inputMethodQuery(Qt.InputMethodQuery query)
This method is only relevant for input items. It is used by the input method to query a set of properties of the item to be able to support complex input method operations, such as support for surrounding text and reconversions. query specifies which property is queried.

See also:
inputMethodEvent().

Specified by:
inputMethodQuery in interface QGraphicsItemInterface

isObscuredBy

public boolean isObscuredBy(QGraphicsItemInterface item)
Returns true if this item's bounding rect is completely obscured by the opaque shape of item.

The base implementation maps item's opaqueArea() to this item's coordinate system, and then checks if this item's boundingRect() is fully contained within the mapped shape.

You can reimplement this function to provide a custom algorithm for determining whether this item is obscured by item.

See also:
opaqueArea(), and isObscured().

Specified by:
isObscuredBy in interface QGraphicsItemInterface

itemChange

public java.lang.Object itemChange(QGraphicsItem.GraphicsItemChange change,
                                   java.lang.Object value)
This virtual function is called by QGraphicsItem to notify custom items that some part of the item's state changes. By reimplementing this function, your can react to a change, and in some cases, (depending on change,) adjustments can be made.

change is the parameter of the item that is changing. value is the new value; the type of the value depends on change.

Example:

The following code example is written in c++.

        QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
        {
            if (change == ItemPositionChange && scene()) {
                // value is the new position.
                QPointF newPos = value.toPointF();
                QRectF rect = scene()->sceneRect();
                if (!rect.contains(newPos)) {
                    // Keep the item inside the scene rect.
                    newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
                    newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
                    return newPos;
                }
            }
            return QGraphicsItem::itemChange(change, value);
        }
The default implementation does nothing, and returns value.

Note: Certain QGraphicsItem functions cannot be called in a reimplementation of this function; see the GraphicsItemChange documentation for details.

See also:
GraphicsItemChange .

Specified by:
itemChange in interface QGraphicsItemInterface

keyPressEvent

public void keyPressEvent(QKeyEvent event)
This event handler, for event event, can be reimplemented to receive key press events for this item. The default implementation ignores the event. If you reimplement this handler, the event will by default be accepted.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

Note that key events are only received for items that set the ItemIsFocusable flag, and that have keyboard input focus.

See also:
keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(), and sceneEvent().

Specified by:
keyPressEvent in interface QGraphicsItemInterface

keyReleaseEvent

public void keyReleaseEvent(QKeyEvent event)
This event handler, for event event, can be reimplemented to receive key release events for this item. The default implementation ignores the event. If you reimplement this handler, the event will by default be accepted.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

Note that key events are only received for items that set the ItemIsFocusable flag, and that have keyboard input focus.

See also:
keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(), and sceneEvent().

Specified by:
keyReleaseEvent in interface QGraphicsItemInterface

mouseDoubleClickEvent

public void mouseDoubleClickEvent(QGraphicsSceneMouseEvent event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for this item.

When doubleclicking an item, the item will first receive a mouse press event, followed by a release event (i.e., a click), then a doubleclick event, and finally a release event.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

The default implementation calls mousePressEvent(). If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mouseDoubleClickEvent() in your reimplementation.

See also:
mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and sceneEvent().

Specified by:
mouseDoubleClickEvent in interface QGraphicsItemInterface

mouseMoveEvent

public void mouseMoveEvent(QGraphicsSceneMouseEvent event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item. If you do receive this event, you can be certain that this item also received a mouse press event, and that this item is the current mouse grabber.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

The default implementation handles basic item interaction, such as selection and moving. If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mouseMoveEvent() in your reimplementation.

See also:
mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), and sceneEvent().

Specified by:
mouseMoveEvent in interface QGraphicsItemInterface

mousePressEvent

public void mousePressEvent(QGraphicsSceneMouseEvent event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item. Mouse press events are only delivered to items that accept the mouse button that is pressed. By default, an item accepts all mouse buttons, but you can change this by calling setAcceptedMouseButtons().

The mouse press event decides which item should become the mouse grabber (see QGraphicsScene::mouseGrabberItem()). If you do not reimplement this function, the press event will propagate to any topmost item beneath this item, and no other mouse events will be delivered to this item.

If you do reimplement this function, event will by default be accepted (see QEvent::accept()), and this item is then the mouse grabber. This allows the item to receive future move, release and doubleclick events. If you call QEvent::ignore() on event, this item will lose the mouse grab, and event will propagate to any topmost item beneath. No further mouse events will be delivered to this item unless a new mouse press event is received.

The default implementation handles basic item interaction, such as selection and moving. If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mousePressEvent() in your reimplementation.

See also:
mouseMoveEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), and sceneEvent().

Specified by:
mousePressEvent in interface QGraphicsItemInterface

mouseReleaseEvent

public void mouseReleaseEvent(QGraphicsSceneMouseEvent event)
This event handler, for event event, can be reimplemented to receive mouse release events for this item.

Calling QEvent::ignore() or QEvent::accept() on event has no effect.

The default implementation handles basic item interaction, such as selection and moving. If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mouseReleaseEvent() in your reimplementation.

See also:
mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(), and sceneEvent().

Specified by:
mouseReleaseEvent in interface QGraphicsItemInterface

moveEvent

protected void moveEvent(QGraphicsSceneMoveEvent event)
This event handler, for GraphicsSceneMove events, is delivered after the widget has moved (e.g., its local position has changed).

This event is only delivered when the item is moved locally. Calling setTransform() or moving any of the item's ancestors does not affect the item's local position.

You can reimplement this event handler to detect when your widget has moved. Calling QEvent::accept() or QEvent::ignore() on event has no effect.

See also:
ItemPositionChange , and ItemPositionHasChanged .


opaqueArea

public QPainterPath opaqueArea()
This virtual function returns a shape representing the area where this item is opaque. An area is opaque if it is filled using an opaque brush or color (i.e., not transparent).

This function is used by isObscuredBy(), which is called by underlying items to determine if they are obscured by this item.

The default implementation returns an empty QPainterPath, indicating that this item is completely transparent and does not obscure any other items.

See also:
isObscuredBy(), isObscured(), and shape().

Specified by:
opaqueArea in interface QGraphicsItemInterface

paint

public void paint(QPainter painter,
                  QStyleOptionGraphicsItem option,
                  QWidget widget)
This function, which is usually called by QGraphicsView, paints the contents of an item in local coordinates.

Reimplement this function in a QGraphicsItem subclass to provide the item's painting implementation, using painter. The option parameter provides style options for the item, such as its state, exposed area and its level-of-detail hints. The widget argument is optional. If provided, it points to the widget that is being painted on; otherwise, it is 0. For cached painting, widget is always 0.

The following code example is written in c++.

        void RoundRectItem::paint(QPainter *painter,
                                  const QStyleOptionGraphicsItem *option,
                                  QWidget *widget)
        {
            painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
        }
The painter's pen is 0-width by default, and its pen is initialized to the QPalette::Text brush from the paint device's palette. The brush is initialized to QPalette::Window .

Make sure to constrain all painting inside the boundaries of boundingRect() to avoid rendering artifacts (as QGraphicsView does not clip the painter for you). In particular, when QPainter renders the outline of a shape using an assigned QPen, half of the outline will be drawn outside, and half inside, the shape you're rendering (e.g., with a pen width of 2 units, you must draw outlines 1 unit inside boundingRect()). QGraphicsItem does not support use of cosmetic pens with a non-zero width.

All painting is done in local coordinates.

See also:
setCacheMode(), QPen::width(), and Item Coordinates.

Specified by:
paint in interface QGraphicsItemInterface

paintWindowFrame

public final void paintWindowFrame(QPainter painter,
                                   QStyleOptionGraphicsItem option)
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. The base implementation uses the current style to render the frame and title bar.

You can reimplement this function in a subclass of QGraphicsWidget to provide custom rendering of the widget's window frame.

See also:
QGraphicsItem::paint().


paintWindowFrame

public void paintWindowFrame(QPainter painter,
                             QStyleOptionGraphicsItem option,
                             QWidget widget)
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. The base implementation uses the current style to render the frame and title bar.

You can reimplement this function in a subclass of QGraphicsWidget to provide custom rendering of the widget's window frame.

See also:
QGraphicsItem::paint().


polishEvent

protected void polishEvent()
This event is delivered to the item by the scene at some point after it has been constructed, but before it is shown or otherwise accessed through the scene. You can use this event handler to do last-minute initializations of the widget which require the item to be fully constructed.

The base implementation does nothing.


propertyChange

protected java.lang.Object propertyChange(java.lang.String propertyName,
                                          java.lang.Object value)
This method is internal to Qt Jambi.


resizeEvent

protected void resizeEvent(QGraphicsSceneResizeEvent event)
This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i.e., its local size has changed). event contains both the old and the new size.

This event is only delivered when the widget is resized locally; calling setTransform() on the widget or any of its ancestors or view, does not affect the widget's local size.

You can reimplement this event handler to detect when your widget has been resized. Calling QEvent::accept() or QEvent::ignore() on event has no effect.

See also:
geometry(), and setGeometry().


sceneEvent

public boolean sceneEvent(QEvent event)
This virtual function receives events to this item. Reimplement this function to intercept events before they are dispatched to the specialized event handlers contextMenuEvent(), focusInEvent(), focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(), hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(), mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and mouseDoubleClickEvent().

Returns true if the event was recognized and handled; otherwise, (e.g., if the event type was not recognized,) false is returned.

event is the intercepted event.

Specified by:
sceneEvent in interface QGraphicsItemInterface

sceneEventFilter

public boolean sceneEventFilter(QGraphicsItemInterface watched,
                                QEvent event)
Filters events for the item watched. event is the filtered event.

Reimplementing this function in a subclass makes it possible for the item to be used as an event filter for other items, intercepting all the events send to those items before they are able to respond.

Reimplementations must return true to prevent further processing of a given event, ensuring that it will not be delivered to the watched item, or return false to indicate that the event should be propagated further by the event system.

See also:
installSceneEventFilter().

Specified by:
sceneEventFilter in interface QGraphicsItemInterface

setExtension

public void setExtension(QGraphicsItem.Extension extension,
                         java.lang.Object variant)
This method is internal to Qt Jambi.

Specified by:
setExtension in interface QGraphicsItemInterface

setGeometry

public void setGeometry(QRectF rect)
This pure virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e.g., the top-left corner of rect is equivalent to the item's position in parent coordinates).

Reimplement this function in a subclass of QGraphicsLayoutItem to enable your item to receive geometry updates.

If rect is outside of the bounds of minimumSize and maximumSize, it will be adjusted to its closest size so that it is within the legal bounds.

See also:
geometry().

Specified by:
setGeometry in interface QGraphicsLayoutItemInterface

shape

public QPainterPath shape()
Returns the shape of this item as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions.

The default implementation calls boundingRect() to return a simple rectangular shape, but subclasses can reimplement this function to return a more accurate shape for non-rectangular items. For example, a round item may choose to return an elliptic shape for better collision detection. For example:

The following code example is written in c++.

        QPainterPath RoundItem::shape() const
        {
            QPainterPath path;
            path.addEllipse(boundingRect());
            return path;
        }
The outline of a shape can vary depending on the width and style of the pen used when drawing. If you want to include this outline in the item's shape, you can create a shape from the stroke using QPainterPathStroker.

This function is called by the default implementations of contains() and collidesWithPath().

See also:
boundingRect(), contains(), prepareGeometryChange(), and QPainterPathStroker.

Specified by:
shape in interface QGraphicsItemInterface

showEvent

protected void showEvent(QShowEvent event)
This event handler, for Show events, is delivered before the widget has been shown, for example, setVisible(true) has been called for the widget or one of its ancestors when the widget was previously hidden.

You can reimplement this event handler to detect when your widget is shown. Calling QEvent::accept() or QEvent::ignore() on event has no effect.

See also:
hideEvent(), QWidget::showEvent(), and ItemVisibleChange .


sizeHint

public QSizeF sizeHint(Qt.SizeHint which,
                       QSizeF constraint)
This pure virtual function returns the size hint for which of the QGraphicsLayoutItem, using the width or height of constraint to constrain the output.

Reimplement this function in a subclass of QGraphicsLayoutItem to provide the necessary size hints for your items.

See also:
effectiveSizeHint().

Specified by:
sizeHint in interface QGraphicsLayoutItemInterface

supportsExtension

public boolean supportsExtension(QGraphicsItem.Extension extension)
This method is internal to Qt Jambi.

Specified by:
supportsExtension in interface QGraphicsItemInterface

type

public int type()
Returns the type of an item as an int. All standard graphicsitem classes are associated with a unique value; see QGraphicsItem::Type. This type information is used by qgraphicsitem_cast() to distinguish between types.

The default implementation (in QGraphicsItem) returns UserType.

To enable use of qgraphicsitem_cast() with a custom item, reimplement this function and declare a Type enum value equal to your custom item's type. Custom items must return a value larger than or equal to UserType (65536).

For example:

The following code example is written in c++.

class CustomItem : public QGraphicsItem
{
   ...
   enum { Type = UserType + 1 };

   int type() const
   {
       // Enable the use of qgraphicsitem_cast with this item.
       return Type;
   }
   ...
};

See also:
UserType.

Specified by:
type in interface QGraphicsItemInterface

ungrabKeyboardEvent

protected void ungrabKeyboardEvent(QEvent event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::UngrabKeyboard events.

See also:
ungrabKeyboard(), and ungrabMouse().


ungrabMouseEvent

protected void ungrabMouseEvent(QEvent event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for Qt::UngrabMouse events.

See also:
ungrabMouse(), and ungrabKeyboard().


updateGeometry

public void updateGeometry()
This virtual function discards any cached size hint information. You should always call this function if you change the return value of the sizeHint() function. Subclasses must always call the base implementation when reimplementing this function.

See also:
effectiveSizeHint().

Specified by:
updateGeometry in interface QGraphicsLayoutItemInterface

wheelEvent

public void wheelEvent(QGraphicsSceneWheelEvent event)
This event handler, for event event, can be reimplemented to receive wheel events for this item. If you reimplement this function, event will be accepted by default.

If you ignore the event, (i.e., by calling QEvent::ignore(),) it will propagate to any item beneath this item. If no items accept the event, it will be ignored by the scene, and propagate to the view (e.g., the view's vertical scroll bar).

The default implementation ignores the event.

See also:
sceneEvent().

Specified by:
wheelEvent in interface QGraphicsItemInterface

windowFrameEvent

protected boolean windowFrameEvent(QEvent e)
This event handler, for event, receives events for the window frame if this widget is a window. Its base implementation provides support for default window frame interaction such as moving, resizing, etc.

You can reimplement this handler in a subclass of QGraphicsWidget to provide your own custom window frame interaction support.

Returns true if event has been recognized and processed; otherwise, returns false.

See also:
event().


windowFrameSectionAt

protected Qt.WindowFrameSection windowFrameSectionAt(QPointF pos)
Returns the window frame section at position pos, or Qt::NoWindowFrameSection if there is no window frame section at this position.

This function is used in QGraphicsWidget's base implementation for window frame interaction.

You can reimplement this function if you want to customize how a window can be interactively moved or resized. For instance, if you only want to allow a window to be resized by the bottom right corner, you can reimplement this function to return Qt::NoSection for all sections except Qt::BottomRightSection .

See also:
windowFrameEvent(), paintWindowFrame(), and windowFrameGeometry().


setTabOrder

public static void setTabOrder(QGraphicsWidget first,
                               QGraphicsWidget second)
Moves the second widget around the ring of focus widgets so that keyboard focus moves from the first widget to the second widget when the Tab key is pressed.

Note that since the tab order of the second widget is changed, you should order a chain like this:

The following code example is written in c++.

        setTabOrder(a, b); // a to b
        setTabOrder(b, c); // a to b to c
        setTabOrder(c, d); // a to b to c to d
not like this:

The following code example is written in c++.
        // WRONG
        setTabOrder(c, d); // c to d
        setTabOrder(a, b); // a to b AND c to d
        setTabOrder(b, c); // a to b to c, but not c to d
If first is 0, this indicates that second should be the first widget to receive input focus should the scene gain Tab focus (i.e., the user hits Tab so that focus passes into the scene). If second is 0, this indicates that first should be the first widget to gain focus if the scene gained BackTab focus.

By default, tab order is defined implicitly using widget creation order.

See also:
focusPolicy, and Keyboard Focus.


fromNativePointer

public static QGraphicsWidget fromNativePointer(QNativePointer nativePointer)
This method returns the QGraphicsWidget instance pointed to by nativePointer.


__qt_cast_to_QGraphicsItem

public long __qt_cast_to_QGraphicsItem(long ptr)
This method is internal to Qt Jambi.

Specified by:
__qt_cast_to_QGraphicsItem in interface QGraphicsItemInterface

__qt_cast_to_QGraphicsLayoutItem

public long __qt_cast_to_QGraphicsLayoutItem(long ptr)
This method is internal to Qt Jambi.

Specified by:
__qt_cast_to_QGraphicsLayoutItem in interface QGraphicsLayoutItemInterface

getWindowFrameMargins

public final QMarginsF getWindowFrameMargins()
Gets the widget's window frame margins.


getContentsMargins

public final QMarginsF getContentsMargins()
Description copied from interface: QGraphicsLayoutItemInterface
This virtual function provides the left, top, right and bottom contents margins for this QGraphicsLayoutItem. The default implementation assumes all contents margins are 0. The parameters point to values stored in qreals. If any of the pointers is 0, that value will not be updated.

See also:
QGraphicsWidget::setContentsMargins().

Specified by:
getContentsMargins in interface QGraphicsLayoutItemInterface