Qt 4.8
Public Types | Public Functions | Protected Slots | Protected Functions | Friends | List of all members
QGraphicsProxyWidget Class Reference

The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene. More...

#include <qgraphicsproxywidget.h>

Inheritance diagram for QGraphicsProxyWidget:
QGraphicsWidget QGraphicsObject QGraphicsLayoutItem QObject QGraphicsItem

Public Types

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

Public Functions

QGraphicsProxyWidgetcreateProxyForChildWidget (QWidget *child)
 Creates a proxy widget for the given child of the widget contained in this proxy. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Reimplemented Function More...
 
 QGraphicsProxyWidget (QGraphicsItem *parent=0, Qt::WindowFlags wFlags=0)
 Constructs a new QGraphicsProxy widget. More...
 
void setGeometry (const QRectF &rect)
 Reimplemented Function More...
 
void setWidget (QWidget *widget)
 Embeds widget into this proxy widget. More...
 
QRectF subWidgetRect (const QWidget *widget) const
 Returns the rectangle for widget, which must be a descendant of widget(), or widget() itself, in this proxy item's local coordinates. More...
 
int type () const
 Reimplemented Function More...
 
QWidgetwidget () const
 Returns a pointer to the embedded widget. More...
 
 ~QGraphicsProxyWidget ()
 Destroys the proxy widget and any embedded widget. More...
 
- Public Functions inherited from QGraphicsWidget
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to its effective preferred size hint. More...
 
bool autoFillBackground () const
 
QRectF boundingRect () const
 Reimplemented Function More...
 
Qt::FocusPolicy focusPolicy () const
 
QGraphicsWidgetfocusWidget () const
 If this widget, a child or descendant of this widget currently has input focus, this function will return a pointer to that widget. More...
 
QFont font () const
 
void getContentsMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const
 Gets the widget's contents margins. More...
 
void getWindowFrameMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const
 Gets the widget's window frame margins. More...
 
int grabShortcut (const QKeySequence &sequence, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
bool isActiveWindow () const
 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). More...
 
QGraphicsLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
 Reimplemented Function More...
 
virtual void paintWindowFrame (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
 This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. More...
 
QPalette palette () const
 
 QGraphicsWidget (QGraphicsItem *parent=0, Qt::WindowFlags wFlags=0)
 Constructs a QGraphicsWidget instance. More...
 
QRectF rect () const
 Returns the item's local rect as a QRectF. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void resize (const QSizeF &size)
 
void resize (qreal w, qreal h)
 This convenience function is equivalent to calling resize(QSizeF(w, h)). More...
 
void setAttribute (Qt::WidgetAttribute attribute, bool on=true)
 If on is true, this function enables attribute; otherwise attribute is disabled. More...
 
void setAutoFillBackground (bool enabled)
 
void setContentsMargins (qreal left, qreal top, qreal right, qreal bottom)
 Sets the widget's contents margins to left, top, right and bottom. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFont (const QFont &font)
 
void setGeometry (const QRectF &rect)
 This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e. More...
 
void setGeometry (qreal x, qreal y, qreal w, qreal h)
 This convenience function is equivalent to calling setGeometry(QRectF( x, y, w, h)). More...
 
void setLayout (QGraphicsLayout *layout)
 Sets the layout for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setPalette (const QPalette &palette)
 
void setShortcutAutoRepeat (int id, bool enabled=true)
 If enabled is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enabled=true)
 If enabled is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setStyle (QStyle *style)
 Sets the widget's style to style. More...
 
void setWindowFlags (Qt::WindowFlags wFlags)
 
void setWindowFrameMargins (qreal left, qreal top, qreal right, qreal bottom)
 Sets the widget's window frame margins to left, top, right and bottom. More...
 
void setWindowTitle (const QString &title)
 
QPainterPath shape () const
 Reimplemented Function More...
 
QSizeF size () const
 
QStylestyle () const
 Returns a pointer to the widget's style. More...
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 Returns true if attribute is enabled for this widget; otherwise, returns false. More...
 
int type () const
 Reimplemented Function More...
 
void unsetLayoutDirection ()
 
void unsetWindowFrameMargins ()
 Resets the window frame margins to the default value, provided by the style. More...
 
Qt::WindowFlags windowFlags () const
 
QRectF windowFrameGeometry () const
 Returns the widget's geometry in parent coordinates including any window frame. More...
 
QRectF windowFrameRect () const
 Returns the widget's local rect including any window frame. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the widgets window type. More...
 
 ~QGraphicsWidget ()
 Destroys the QGraphicsWidget instance. More...
 
- Public Functions inherited from QGraphicsObject
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the graphics object to the given gesture with specific flags. More...
 
 QGraphicsObject (QGraphicsItem *parent=0)
 Constructs a QGraphicsObject with parent. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the graphics object from the given gesture. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QGraphicsItem
bool acceptDrops () const
 Returns true if this item can accept drag and drop events; otherwise, returns false. More...
 
Qt::MouseButtons acceptedMouseButtons () const
 Returns the mouse buttons that this item accepts mouse events for. More...
 
bool acceptHoverEvents () const
 Returns true if an item accepts hover events (QGraphicsSceneHoverEvent); otherwise, returns false. More...
 
bool acceptsHoverEvents () const
 Call acceptHoverEvents() instead. More...
 
bool acceptTouchEvents () const
 Returns true if an item accepts touch events; otherwise, returns false. More...
 
virtual void advance (int phase)
 This virtual function is called twice for all items by the QGraphicsScene::advance() slot. More...
 
QRegion boundingRegion (const QTransform &itemToDeviceTransform) const
 Returns the bounding region for this item. More...
 
qreal boundingRegionGranularity () const
 Returns the item's bounding region granularity; a value between and including 0 and 1. More...
 
CacheMode cacheMode () const
 Returns the cache mode for this item. More...
 
QList< QGraphicsItem * > childItems () const
 Returns a list of this item's children. More...
 
QList< QGraphicsItem * > children () const
 Use childItems() instead. More...
 
QRectF childrenBoundingRect () const
 Returns the bounding rect of this item's descendants (i.e., its children, their children, etc.) in local coordinates. More...
 
void clearFocus ()
 Takes keyboard input focus from the item. More...
 
QPainterPath clipPath () const
 Returns this item's clip path, or an empty QPainterPath if this item is not clipped. More...
 
virtual bool collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns true if this item collides with other; otherwise returns false. More...
 
virtual bool collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns true if this item collides with path. More...
 
QList< QGraphicsItem * > collidingItems (Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns a list of all items that collide with this item. More...
 
QGraphicsItemcommonAncestorItem (const QGraphicsItem *other) const
 Returns the closest common ancestor item of this item and other, or 0 if either other is 0, or there is no common ancestor. More...
 
virtual bool contains (const QPointF &point) const
 Returns true if this item contains point, which is in local coordinates; otherwise, false is returned. More...
 
QCursor cursor () const
 Returns the current cursor shape for the item. More...
 
QVariant data (int key) const
 Returns this item's custom data for the key key as a QVariant. More...
 
QTransform deviceTransform (const QTransform &viewportTransform) const
 Returns this item's device transformation matrix, using viewportTransform to map from scene to device coordinates. More...
 
qreal effectiveOpacity () const
 Returns this item's effective opacity, which is between 0. More...
 
void ensureVisible (const QRectF &rect=QRectF(), int xmargin=50, int ymargin=50)
 If this item is part of a scene that is viewed by a QGraphicsView, this convenience function will attempt to scroll the view to ensure that rect is visible inside the view's viewport. More...
 
void ensureVisible (qreal x, qreal y, qreal w, qreal h, int xmargin=50, int ymargin=50)
 This convenience function is equivalent to calling ensureVisible(QRectF(x, y, w, h), xmargin, ymargin): More...
 
bool filtersChildEvents () const
 Returns true if this item filters child events (i. More...
 
GraphicsItemFlags flags () const
 Returns this item's flags. More...
 
QGraphicsItemfocusItem () const
 If this item, a child or descendant of this item currently has input focus, this function will return a pointer to that item. More...
 
QGraphicsItemfocusProxy () const
 Returns this item's focus proxy, or 0 if this item has no focus proxy. More...
 
QGraphicsItemfocusScopeItem () const
 Returns this item's focus scope item. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
QGraphicsEffectgraphicsEffect () const
 Returns a pointer to this item's effect if it has one; otherwise 0. More...
 
QGraphicsItemGroupgroup () const
 Returns a pointer to this item's item group, or 0 if this item is not member of a group. More...
 
bool handlesChildEvents () const
 Returns true if this item handles child events (i. More...
 
bool hasCursor () const
 Returns true if this item has a cursor set; otherwise, false is returned. More...
 
bool hasFocus () const
 Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise, returns false. More...
 
void hide ()
 Hides the item. More...
 
Qt::InputMethodHints inputMethodHints () const
 Returns the current input method hints of this item. More...
 
void installSceneEventFilter (QGraphicsItem *filterItem)
 Installs an event filter for this item on filterItem, causing all events for this item to first pass through filterItem's sceneEventFilter() function. More...
 
bool isActive () const
 Returns true if this item is active; otherwise returns false. More...
 
bool isAncestorOf (const QGraphicsItem *child) const
 Returns true if this item is an ancestor of child (i.e., if this item is child's parent, or one of child's parent's ancestors). More...
 
bool isBlockedByModalPanel (QGraphicsItem **blockingPanel=0) const
 Returns true if this item is blocked by a modal panel, false otherwise. More...
 
bool isClipped () const
 Returns true if this item is clipped. More...
 
bool isEnabled () const
 Returns true if the item is enabled; otherwise, false is returned. More...
 
bool isObscured () const
 Returns true if this item's bounding rect is completely obscured by the opaque shape of any of colliding items above it (i.e., with a higher Z value than this item). More...
 
bool isObscured (const QRectF &rect) const
 Returns true if rect is completely obscured by the opaque shape of any of colliding items above it (i. More...
 
bool isObscured (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling isObscured(QRectF(x, y, w, h)). More...
 
virtual bool isObscuredBy (const QGraphicsItem *item) const
 Returns true if this item's bounding rect is completely obscured by the opaque shape of item. More...
 
bool isPanel () const
 Returns true if the item is a panel; otherwise returns false. More...
 
bool isSelected () const
 Returns true if this item is selected; otherwise, false is returned. More...
 
bool isUnderMouse () const
 Returns true if this item is currently under the mouse cursor in one of the views; otherwise, false is returned. More...
 
bool isVisible () const
 Returns true if the item is visible; otherwise, false is returned. More...
 
bool isVisibleTo (const QGraphicsItem *parent) const
 Returns true if the item is visible to parent; otherwise, false is returned. More...
 
bool isWidget () const
 Returns true if this item is a widget (i. More...
 
bool isWindow () const
 Returns true if the item is a QGraphicsWidget window, otherwise returns false. More...
 
QTransform itemTransform (const QGraphicsItem *other, bool *ok=0) const
 Returns a QTransform that maps coordinates from this item to other. More...
 
QPointF mapFromItem (const QGraphicsItem *item, const QPointF &point) const
 Maps the point point, which is in item's coordinate system, to this item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in item's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 Maps the polygon polygon, which is in item's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromItem (const QGraphicsItem *item, const QPainterPath &path) const
 Maps the path path, which is in item's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromItem (const QGraphicsItem *item, qreal x, qreal y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This convenience function is equivalent to calling mapFromItem(item, QPointF(x, y)). More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapFromParent (const QPointF &point) const
 Maps the point point, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapFromParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromParent (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromParent (const QPainterPath &path) const
 Maps the path path, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromParent (qreal x, qreal y) const
 This convenience function is equivalent to calling mapFromParent(QPointF(x, y)). More...
 
QPolygonF mapFromParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapFromItem(QRectF(x, y, w, h)). More...
 
QPointF mapFromScene (const QPointF &point) const
 Maps the point point, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapFromScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromScene (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromScene (const QPainterPath &path) const
 Maps the path path, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromScene (qreal x, qreal y) const
 This convenience function is equivalent to calling mapFromScene(QPointF(x, y)). More...
 
QPolygonF mapFromScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapFromScene(QRectF(x, y, w, h)). More...
 
QRectF mapRectFromItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in item's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectFromParent(QRectF(x, y, w, h)). More...
 
QRectF mapRectFromScene (const QRectF &rect) const
 Maps the rectangle rect, which is in scene coordinates, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectFromScene(QRectF(x, y, w, h)). More...
 
QRectF mapRectToItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectToParent(QRectF(x, y, w, h)). More...
 
QRectF mapRectToScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to the scene coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectToScene(QRectF(x, y, w, h)). More...
 
QPointF mapToItem (const QGraphicsItem *item, const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToItem (const QGraphicsItem *item, const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to item's coordinate system, and returns the mapped path. More...
 
QPointF mapToItem (const QGraphicsItem *item, qreal x, qreal y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This convenience function is equivalent to calling mapToItem(item, QPointF(x, y)). More...
 
QPolygonF mapToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapToParent (const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToParent (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToParent (const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped path. More...
 
QPointF mapToParent (qreal x, qreal y) const
 This convenience function is equivalent to calling mapToParent(QPointF(x, y)). More...
 
QPolygonF mapToParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapToParent(QRectF(x, y, w, h)). More...
 
QPointF mapToScene (const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToScene (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToScene (const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped path. More...
 
QPointF mapToScene (qreal x, qreal y) const
 This convenience function is equivalent to calling mapToScene(QPointF(x, y)). More...
 
QPolygonF mapToScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapToScene(QRectF(x, y, w, h)). More...
 
QMatrix matrix () const
 Returns the item's affine transformation matrix. More...
 
void moveBy (qreal dx, qreal dy)
 Moves the item by dx points horizontally, and dy point vertically. More...
 
qreal opacity () const
 Returns this item's local opacity, which is between 0. More...
 
virtual QPainterPath opaqueArea () const
 This virtual function returns a shape representing the area where this item is opaque. More...
 
QGraphicsItempanel () const
 Returns the item's panel, or 0 if this item does not have a panel. More...
 
PanelModality panelModality () const
 Returns the modality for this item. More...
 
QGraphicsItemparentItem () const
 Returns a pointer to this item's parent item. More...
 
QGraphicsObjectparentObject () const
 Returns a pointer to the item's parent, cast to a QGraphicsObject. More...
 
QGraphicsWidgetparentWidget () const
 Returns a pointer to the item's parent widget. More...
 
QPointF pos () const
 Returns the position of the item in parent coordinates. More...
 
 QGraphicsItem (QGraphicsItem *parent=0)
 Constructs a QGraphicsItem with the given parent item. More...
 
void removeSceneEventFilter (QGraphicsItem *filterItem)
 Removes an event filter on this item from filterItem. More...
 
void resetMatrix ()
 Use resetTransform() instead. More...
 
void resetTransform ()
 Resets this item's transformation matrix to the identity matrix or all the transformation properties to their default values. More...
 
void rotate (qreal angle)
 Use. More...
 
qreal rotation () const
 Returns the clockwise rotation, in degrees, around the Z axis. More...
 
void scale (qreal sx, qreal sy)
 Use. More...
 
qreal scale () const
 Returns the scale factor of the item. More...
 
QGraphicsScenescene () const
 Returns the current scene for the item, or 0 if the item is not stored in a scene. More...
 
QRectF sceneBoundingRect () const
 Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(). More...
 
QMatrix sceneMatrix () const
 Use sceneTransform() instead. More...
 
QPointF scenePos () const
 Returns the item's position in scene coordinates. More...
 
QTransform sceneTransform () const
 Returns this item's scene transformation matrix. More...
 
void scroll (qreal dx, qreal dy, const QRectF &rect=QRectF())
 Scrolls the contents of rect by dx, dy. More...
 
void setAcceptDrops (bool on)
 If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and drop events. More...
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 Sets the mouse buttons that this item accepts mouse events for. More...
 
void setAcceptHoverEvents (bool enabled)
 If enabled is true, this item will accept hover events; otherwise, it will ignore them. More...
 
void setAcceptsHoverEvents (bool enabled)
 Use setAcceptHoverEvents(enabled) instead. More...
 
void setAcceptTouchEvents (bool enabled)
 If enabled is true, this item will accept touch events; otherwise, it will ignore them. More...
 
void setActive (bool active)
 If active is true, and the scene is active, this item's panel will be activated. More...
 
void setBoundingRegionGranularity (qreal granularity)
 Sets the bounding region granularity to granularity; a value between and including 0 and 1. More...
 
void setCacheMode (CacheMode mode, const QSize &cacheSize=QSize())
 Sets the item's cache mode to mode. More...
 
void setCursor (const QCursor &cursor)
 Sets the current cursor shape for the item to cursor. More...
 
void setData (int key, const QVariant &value)
 Sets this item's custom data for the key key to value. More...
 
void setEnabled (bool enabled)
 If enabled is true, the item is enabled; otherwise, it is disabled. More...
 
void setFiltersChildEvents (bool enabled)
 If enabled is true, this item is set to filter all events for all its children (i. More...
 
void setFlag (GraphicsItemFlag flag, bool enabled=true)
 If enabled is true, the item flag flag is enabled; otherwise, it is disabled. More...
 
void setFlags (GraphicsItemFlags flags)
 Sets the item flags to flags. More...
 
void setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason)
 Gives keyboard input focus to this item. More...
 
void setFocusProxy (QGraphicsItem *item)
 Sets the item's focus proxy to item. More...
 
void setGraphicsEffect (QGraphicsEffect *effect)
 Sets effect as the item's effect. More...
 
void setGroup (QGraphicsItemGroup *group)
 Adds this item to the item group group. More...
 
void setHandlesChildEvents (bool enabled)
 If enabled is true, this item is set to handle all events for all its children (i. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 Sets the current input method hints of this item to hints. More...
 
void setMatrix (const QMatrix &matrix, bool combine=false)
 Sets the item's affine transformation matrix. More...
 
void setOpacity (qreal opacity)
 Sets this item's local opacity, between 0. More...
 
void setPanelModality (PanelModality panelModality)
 Sets the modality for this item to panelModality. More...
 
void setParentItem (QGraphicsItem *parent)
 Sets this item's parent item to newParent. More...
 
void setPos (const QPointF &pos)
 Sets the position of the item to pos, which is in parent coordinates. More...
 
void setPos (qreal x, qreal y)
 This convenience function is equivalent to calling setPos(QPointF(x, y)). More...
 
void setRotation (qreal angle)
 Sets the clockwise rotation angle, in degrees, around the Z axis. More...
 
void setScale (qreal scale)
 Sets the scale factor of the item. More...
 
void setSelected (bool selected)
 If selected is true and this item is selectable, this item is selected; otherwise, it is unselected. More...
 
void setToolTip (const QString &toolTip)
 Sets the item's tool tip to toolTip. More...
 
void setTransform (const QTransform &matrix, bool combine=false)
 Sets the item's current transformation matrix to matrix. More...
 
void setTransformations (const QList< QGraphicsTransform *> &transformations)
 Sets a list of graphics transformations (QGraphicsTransform) that currently apply to this item. More...
 
void setTransformOriginPoint (const QPointF &origin)
 Sets the origin point for the transformation in item coordinates. More...
 
void setTransformOriginPoint (qreal ax, qreal ay)
 Sets the origin point for the transformation in item coordinates. More...
 
void setVisible (bool visible)
 If visible is true, the item is made visible. More...
 
void setX (qreal x)
 Set's the x coordinate of the item's position. More...
 
void setY (qreal y)
 Set's the y coordinate of the item's position. More...
 
void setZValue (qreal z)
 Sets the Z-value of the item to z. More...
 
void shear (qreal sh, qreal sv)
 Use. More...
 
void show ()
 Shows the item. More...
 
void stackBefore (const QGraphicsItem *sibling)
 Stacks this item before sibling, which must be a sibling item (i. More...
 
QGraphicsObjecttoGraphicsObject ()
 Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object, 0 otherwise. More...
 
const QGraphicsObjecttoGraphicsObject () const
 Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object, 0 otherwise. More...
 
QString toolTip () const
 Returns the item's tool tip, or an empty QString if no tool tip has been set. More...
 
QGraphicsItemtopLevelItem () const
 Returns this item's top-level item. More...
 
QGraphicsWidgettopLevelWidget () const
 Returns a pointer to the item's top level widget (i. More...
 
QTransform transform () const
 Returns this item's transformation matrix. More...
 
QList< QGraphicsTransform * > transformations () const
 Returns a list of graphics transforms that currently apply to this item. More...
 
QPointF transformOriginPoint () const
 Returns the origin point for the transformation in item coordinates. More...
 
void translate (qreal dx, qreal dy)
 Use setPos() or setTransformOriginPoint() instead. More...
 
void ungrabKeyboard ()
 Releases the keyboard grab. More...
 
void ungrabMouse ()
 Releases the mouse grab. More...
 
void unsetCursor ()
 Clears the cursor from this item. More...
 
void update (const QRectF &rect=QRectF())
 Schedules a redraw of the area covered by rect in this item. More...
 
void update (qreal x, qreal y, qreal width, qreal height)
 This convenience function is equivalent to calling update(QRectF(x, y, width, height)). More...
 
QGraphicsWidgetwindow () const
 Returns the item's window, or 0 if this item does not have a window. More...
 
qreal x () const
 This convenience function is equivalent to calling pos(). More...
 
qreal y () const
 This convenience function is equivalent to calling pos(). More...
 
qreal zValue () const
 Returns the Z-value of the item. More...
 
virtual ~QGraphicsItem ()
 Destroys the QGraphicsItem and all its children. More...
 
- Public Functions inherited from QGraphicsLayoutItem
QRectF contentsRect () const
 Returns the contents rect in local coordinates. More...
 
QSizeF effectiveSizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 Returns the effective size hint for this QGraphicsLayoutItem. More...
 
QRectF geometry () const
 Returns the item's geometry (e. More...
 
QGraphicsItemgraphicsItem () const
 Returns the QGraphicsItem that this layout item represents. More...
 
bool isLayout () const
 Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false. More...
 
qreal maximumHeight () const
 Returns the maximum height. More...
 
QSizeF maximumSize () const
 Returns the maximum size. More...
 
qreal maximumWidth () const
 Returns the maximum width. More...
 
qreal minimumHeight () const
 Returns the minimum height. More...
 
QSizeF minimumSize () const
 Returns the minimum size. More...
 
qreal minimumWidth () const
 Returns the minimum width. More...
 
bool ownedByLayout () const
 Returns whether a layout should delete this item in its destructor. More...
 
QGraphicsLayoutItemparentLayoutItem () const
 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). More...
 
qreal preferredHeight () const
 Returns the preferred height. More...
 
QSizeF preferredSize () const
 Returns the preferred size. More...
 
qreal preferredWidth () const
 Returns the preferred width. More...
 
 QGraphicsLayoutItem (QGraphicsLayoutItem *parent=0, bool isLayout=false)
 Constructs the QGraphicsLayoutItem object. More...
 
void setMaximumHeight (qreal height)
 Sets the maximum height to height. More...
 
void setMaximumSize (const QSizeF &size)
 Sets the maximum size to size. More...
 
void setMaximumSize (qreal w, qreal h)
 This convenience function is equivalent to calling setMaximumSize(QSizeF(w, h)). More...
 
void setMaximumWidth (qreal width)
 Sets the maximum width to width. More...
 
void setMinimumHeight (qreal height)
 Sets the minimum height to height. More...
 
void setMinimumSize (const QSizeF &size)
 Sets the minimum size to size. More...
 
void setMinimumSize (qreal w, qreal h)
 This convenience function is equivalent to calling setMinimumSize(QSizeF(w, h)). More...
 
void setMinimumWidth (qreal width)
 Sets the minimum width to width. More...
 
void setParentLayoutItem (QGraphicsLayoutItem *parent)
 Sets the parent of this QGraphicsLayoutItem to parent. More...
 
void setPreferredHeight (qreal height)
 Sets the preferred height to height. More...
 
void setPreferredSize (const QSizeF &size)
 Sets the preferred size to size. More...
 
void setPreferredSize (qreal w, qreal h)
 This convenience function is equivalent to calling setPreferredSize(QSizeF(w, h)). More...
 
void setPreferredWidth (qreal width)
 Sets the preferred width to width. More...
 
void setSizePolicy (const QSizePolicy &policy)
 Sets the size policy to policy. More...
 
void setSizePolicy (QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType=QSizePolicy::DefaultType)
 This function is equivalent to calling setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)). More...
 
QSizePolicy sizePolicy () const
 Returns the current size policy. More...
 
virtual ~QGraphicsLayoutItem ()
 Destroys the QGraphicsLayoutItem object. More...
 

Protected Slots

QGraphicsProxyWidgetnewProxyWidget (const QWidget *)
 
- Protected Slots inherited from QGraphicsObject
void updateMicroFocus ()
 Updates the item's micro focus. More...
 

Protected Functions

void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 Reimplemented Function More...
 
void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
void dropEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
bool event (QEvent *event)
 Reimplemented Function More...
 
bool eventFilter (QObject *object, QEvent *event)
 Reimplemented Function More...
 
void focusInEvent (QFocusEvent *event)
 Reimplemented Function More...
 
bool focusNextPrevChild (bool next)
 Reimplemented Function More...
 
void focusOutEvent (QFocusEvent *event)
 Reimplemented Function More...
 
void grabMouseEvent (QEvent *event)
 Reimplemented Function More...
 
void hideEvent (QHideEvent *event)
 Reimplemented Function More...
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 Reimplemented Function More...
 
void keyPressEvent (QKeyEvent *event)
 Reimplemented Function More...
 
void keyReleaseEvent (QKeyEvent *event)
 Reimplemented Function More...
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void mousePressEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void resizeEvent (QGraphicsSceneResizeEvent *event)
 Reimplemented Function More...
 
void showEvent (QShowEvent *event)
 Reimplemented Function More...
 
QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 Reimplemented Function More...
 
void ungrabMouseEvent (QEvent *event)
 Reimplemented Function More...
 
void wheelEvent (QGraphicsSceneWheelEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QGraphicsWidget
virtual void changeEvent (QEvent *event)
 This event handler can be reimplemented to handle state changes. More...
 
virtual void closeEvent (QCloseEvent *event)
 This event handler, for event, can be reimplemented in a subclass to receive widget close events. More...
 
bool event (QEvent *event)
 Handles the event. More...
 
void focusInEvent (QFocusEvent *event)
 Reimplemented Function More...
 
void focusOutEvent (QFocusEvent *event)
 Reimplemented Function More...
 
virtual void grabKeyboardEvent (QEvent *event)
 This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::GrabKeyboard events. More...
 
virtual void initStyleOption (QStyleOption *option) const
 Populates a style option object for this widget based on its current state, and stores the output in option. More...
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 QGraphicsWidget uses the base implementation of this function to catch and deliver events related to state changes in the item. More...
 
virtual void moveEvent (QGraphicsSceneMoveEvent *event)
 This event handler, for GraphicsSceneMove events, is delivered after the widget has moved (e.g., its local position has changed). More...
 
virtual 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. More...
 
virtual QVariant propertyChange (const QString &propertyName, const QVariant &value)
 This virtual function is used to notify changes to any property (both dynamic properties, and registered with e.g., "size";, and value is the (proposed) new value of the property. More...
 
 QGraphicsWidget (QGraphicsWidgetPrivate &, QGraphicsItem *parent, QGraphicsScene *, Qt::WindowFlags wFlags=0)
 Constructs a new QGraphicsWidget, using dd as parent. More...
 
bool sceneEvent (QEvent *event)
 QGraphicsWidget's implementation of sceneEvent() simply passes event to QGraphicsWidget::event(). More...
 
QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 Reimplemented Function More...
 
virtual void ungrabKeyboardEvent (QEvent *event)
 This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::UngrabKeyboard events. More...
 
void updateGeometry ()
 If this widget is currently managed by a layout, this function notifies the layout that the widget's size hints have changed and the layout may need to resize and reposition the widget accordingly. More...
 
virtual bool windowFrameEvent (QEvent *e)
 This event handler, for event, receives events for the window frame if this widget is a window. More...
 
virtual Qt::WindowFrameSection windowFrameSectionAt (const QPointF &pos) const
 Returns the window frame section at position pos, or Qt::NoSection if there is no window frame section at this position. More...
 
- Protected Functions inherited from QGraphicsObject
 QGraphicsObject (QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QGraphicsItem
void addToIndex ()
 Adds this item to the scene's index. More...
 
virtual QVariant extension (const QVariant &variant) const
 Note: This is provided as a hook to avoid future problems related to adding virtual functions. More...
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 This event handler, for event event, can be reimplemented to receive input method events for this item. More...
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 This method is only relevant for input items. More...
 
void prepareGeometryChange ()
 Prepares the item for a geometry change. More...
 
 QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
 
void removeFromIndex ()
 Removes this item from the scene's index. More...
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 Filters events for the item watched. More...
 
virtual void setExtension (Extension extension, const QVariant &variant)
 Note: This is provided as a hook to avoid future problems related to adding virtual functions. More...
 
virtual bool supportsExtension (Extension extension) const
 Note: This is provided as a hook to avoid future problems related to adding virtual functions. More...
 
void updateMicroFocus ()
 Updates the item's micro focus. More...
 
- Protected Functions inherited from QGraphicsLayoutItem
 QGraphicsLayoutItem (QGraphicsLayoutItemPrivate &dd)
 
void setGraphicsItem (QGraphicsItem *item)
 If the QGraphicsLayoutItem represents a QGraphicsItem, and it wants to take advantage of the automatic reparenting capabilities of QGraphicsLayout it should set this value. More...
 
void setOwnedByLayout (bool ownedByLayout)
 Sets whether a layout should delete this item in its destructor or not. More...
 

Friends

class QGraphicsItem
 
class QWidget
 
class QWidgetPrivate
 

Additional Inherited Members

- Public Slots inherited from QGraphicsWidget
bool close ()
 Call this function to close the widget. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QGraphicsWidget
void geometryChanged ()
 This signal gets emitted whenever the geometry is changed in setGeometry(). More...
 
void layoutChanged ()
 This signal gets emitted whenever the layout of the item changes. More...
 
- Signals inherited from QGraphicsObject
void childrenChanged ()
 This signal gets emitted whenever the children list changes. More...
 
void enabledChanged ()
 This signal gets emitted whenever the item get's enabled or disabled. More...
 
void heightChanged ()
 
void opacityChanged ()
 This signal gets emitted whenever the opacity of the item changes. More...
 
void parentChanged ()
 This signal gets emitted whenever the parent of the item changes. More...
 
void rotationChanged ()
 This signal gets emitted whenever the roation of the item changes. More...
 
void scaleChanged ()
 This signal is emitted when the scale of the item changes. More...
 
void visibleChanged ()
 This signal gets emitted whenever the visibility of the item changes. More...
 
void widthChanged ()
 
void xChanged ()
 This signal gets emitted whenever the x position of the item changes. More...
 
void yChanged ()
 This signal gets emitted whenever the y position of the item changes. More...
 
void zChanged ()
 This signal gets emitted whenever the z value of the item changes. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QGraphicsWidget
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. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Types inherited from QGraphicsItem
enum  Extension { UserExtension = 0x80000000 }
 Note: This is provided as a hook to avoid future problems related to adding virtual functions. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QGraphicsItem
QScopedPointer< QGraphicsItemPrivated_ptr
 
- Protected Variables inherited from QGraphicsLayoutItem
QScopedPointer< QGraphicsLayoutItemPrivated_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.

Since
4.4

QGraphicsProxyWidget embeds QWidget-based widgets, for example, a QPushButton, QFontComboBox, or even QFileDialog, into QGraphicsScene. It forwards events between the two objects and translates between QWidget's integer-based geometry and QGraphicsWidget's qreal-based geometry. QGraphicsProxyWidget supports all core features of QWidget, including tab focus, keyboard input, Drag & Drop, and popups. You can also embed complex widgets, e.g., widgets with subwidgets.

Example:

int main(int argc, char **argv)
{
QApplication app(argc, argv);
QTabWidget *tabWidget = new QTabWidget;
QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);
QGraphicsView view(&scene);
view.show();
return app.exec();
}

QGraphicsProxyWidget takes care of automatically embedding popup children of embedded widgets through creating a child proxy for each popup. This means that when an embedded QComboBox shows its popup list, a new QGraphicsProxyWidget is created automatically, embedding the popup, and positioning it correctly. This only works if the popup is child of the embedded widget (for example QToolButton::setMenu() requires the QMenu instance to be child of the QToolButton).

Embedding a Widget with QGraphicsProxyWidget

There are two ways to embed a widget using QGraphicsProxyWidget. The most common way is to pass a widget pointer to QGraphicsScene::addWidget() together with any relevant Qt::WindowFlags . This function returns a pointer to a QGraphicsProxyWidget. You can then choose to reparent or position either the proxy, or the embedded widget itself.

For example, in the code snippet below, we embed a group box into the proxy:

QGroupBox *groupBox = new QGroupBox("Contact Details");
QLabel *numberLabel = new QLabel("Telephone number");
QLineEdit *numberEdit = new QLineEdit;
layout->addRow(numberLabel, numberEdit);
groupBox->setLayout(layout);
QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);
QGraphicsView view(&scene);
view.show();

The image below is the output obtained with its contents margin and contents rect labeled.

qgraphicsproxywidget-embed.png

Alternatively, you can start by creating a new QGraphicsProxyWidget item, and then call setWidget() to embed a QWidget later. The widget() function returns a pointer to the embedded widget. QGraphicsProxyWidget shares ownership with QWidget, so if either of the two widgets are destroyed, the other widget will be automatically destroyed as well.

Synchronizing Widget States

QGraphicsProxyWidget keeps its state in sync with the embedded widget. For example, if the proxy is hidden or disabled, the embedded widget will be hidden or disabled as well, and vice versa. When the widget is embedded by calling addWidget(), QGraphicsProxyWidget copies the state from the widget into the proxy, and after that, the two will stay synchronized where possible. By default, when you embed a widget into a proxy, both the widget and the proxy will be visible because a QGraphicsWidget is visible when created (you do not have to call show()). If you explicitly hide the embedded widget, the proxy will also become invisible.

Example:

QLineEdit *edit = new QLineEdit;
QGraphicsProxyWidget *proxy = scene.addWidget(edit);
edit->isVisible(); // returns true
proxy->isVisible(); // also returns true
edit->hide();
edit->isVisible(); // returns false
proxy->isVisible(); // also returns false

QGraphicsProxyWidget maintains symmetry for the following states:

QWidget state QGraphicsProxyWidget state Notes
QWidget::enabled QGraphicsProxyWidget::enabled
QWidget::visible QGraphicsProxyWidget::visible The explicit state is also symmetric.
QWidget::geometry QGraphicsProxyWidget::geometry Geometry is only guaranteed to be symmetric while the embedded widget is visible.
QWidget::layoutDirection QGraphicsProxyWidget::layoutDirection
QWidget::style QGraphicsProxyWidget::style
QWidget::palette QGraphicsProxyWidget::palette
QWidget::font QGraphicsProxyWidget::font
QWidget::cursor QGraphicsProxyWidget::cursor The embedded widget overrides the proxy widget cursor. The proxy cursor changes depending on which embedded subwidget is currently under the mouse.
QWidget::sizeHint() QGraphicsProxyWidget::sizeHint() All size hint functionality from the embedded widget is forwarded by the proxy.
QWidget::getContentsMargins() QGraphicsProxyWidget::getContentsMargins() Updated once by setWidget().
QWidget::windowTitle QGraphicsProxyWidget::windowTitle Updated once by setWidget().
Note
QGraphicsScene keeps the embedded widget in a special state that prevents it from disturbing other widgets (both embedded and not embedded) while the widget is embedded. In this state, the widget may differ slightly in behavior from when it is not embedded.
Warning
This class is provided for convenience when bridging QWidgets and QGraphicsItems, it should not be used for high-performance scenarios.
See also
QGraphicsScene::addWidget(), QGraphicsWidget

Definition at line 57 of file qgraphicsproxywidget.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 73 of file qgraphicsproxywidget.h.

73  {
74  Type = 12
75  };

Constructors and Destructors

◆ QGraphicsProxyWidget()

QGraphicsProxyWidget::QGraphicsProxyWidget ( QGraphicsItem parent = 0,
Qt::WindowFlags  wFlags = 0 
)

Constructs a new QGraphicsProxy widget.

parent and wFlags are passed to QGraphicsItem's constructor.

Definition at line 546 of file qgraphicsproxywidget.cpp.

Referenced by newProxyWidget().

547  : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, 0, wFlags)
548 {
550  d->init();
551 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QGraphicsWidget(QGraphicsItem *parent=0, Qt::WindowFlags wFlags=0)
Constructs a QGraphicsWidget instance.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ ~QGraphicsProxyWidget()

QGraphicsProxyWidget::~QGraphicsProxyWidget ( )

Destroys the proxy widget and any embedded widget.

Definition at line 556 of file qgraphicsproxywidget.cpp.

557 {
559  if (d->widget) {
560  QObject::disconnect(d->widget, SIGNAL(destroyed()), this, SLOT(_q_removeWidgetSlot()));
561  delete d->widget;
562  }
563 }
double d
Definition: qnumeric_p.h:62
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895

Functions

◆ contextMenuEvent()

void QGraphicsProxyWidget::contextMenuEvent ( QGraphicsSceneContextMenuEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1022 of file qgraphicsproxywidget.cpp.

1023 {
1025  if (!event || !d->widget || !d->widget->isVisible() || !hasFocus())
1026  return;
1027 
1028  // Find widget position and receiver.
1029  QPointF pos = event->pos();
1030  QPointer<QWidget> alienWidget = d->widget->childAt(pos.toPoint());
1031  QPointer<QWidget> receiver = alienWidget ? alienWidget : d->widget;
1032 
1033  // Map event position from us to the receiver
1034  pos = d->mapToReceiver(pos, receiver);
1035 
1036  QPoint globalPos = receiver->mapToGlobal(pos.toPoint());
1037  //If the receiver by-pass the proxy its popups
1038  //will be top level QWidgets therefore they need
1039  //the screen position. mapToGlobal expect the widget to
1040  //have proper coordinates in regards of the windowing system
1041  //but it's not true because the widget is embedded.
1042  if (bypassGraphicsProxyWidget(receiver))
1043  globalPos = event->screenPos();
1044 
1045  // Send mouse event. ### Doesn't propagate the event.
1047  pos.toPoint(), globalPos, event->modifiers());
1049 
1050  event->setAccepted(contextMenuEvent.isAccepted());
1051 }
double d
Definition: qnumeric_p.h:62
bool hasFocus() const
Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise...
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
Reason
This enum describes the reason why the event was sent.
Definition: qevent.h:399
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF pos() const
Returns the position of the item in parent coordinates.
static bool bypassGraphicsProxyWidget(const QWidget *p)
Returns true if p or any of its parents enable the Qt::BypassGraphicsProxyWidget window flag...
Definition: qwidget_p.h:353
#define Q_D(Class)
Definition: qglobal.h:2482
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the the context menu was...
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Reimplemented Function
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
Reason reason() const
Returns the reason for the context menu event.

◆ createProxyForChildWidget()

QGraphicsProxyWidget * QGraphicsProxyWidget::createProxyForChildWidget ( QWidget child)

Creates a proxy widget for the given child of the widget contained in this proxy.

Since
4.5

This function makes it possible to acquire proxies for non top-level widgets. For instance, you can embed a dialog, and then transform only one of its widgets.

If the widget is already embedded, return the existing proxy widget.

See also
newProxyWidget(), QGraphicsScene::addWidget()

Definition at line 1529 of file qgraphicsproxywidget.cpp.

1530 {
1531  QGraphicsProxyWidget *proxy = child->graphicsProxyWidget();
1532  if (proxy)
1533  return proxy;
1534  if (!child->parentWidget()) {
1535  qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
1536  return 0;
1537  }
1538 
1540  if (!parentProxy)
1541  return 0;
1542 
1543  if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
1544  Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child)))
1545  return 0;
1546  proxy->setParent(parentProxy);
1547  proxy->setWidget(child);
1548  return proxy;
1549 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setWidget(QWidget *widget)
Embeds widget into this proxy widget.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ARG(type, data)
Definition: qobjectdefs.h:246
QGraphicsProxyWidget * graphicsProxyWidget() const
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns ...
Definition: qwidget.cpp:12939
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_RETURN_ARG(type, data)
Definition: qobjectdefs.h:247
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
QGraphicsProxyWidget * createProxyForChildWidget(QWidget *child)
Creates a proxy widget for the given child of the widget contained in this proxy. ...

◆ dragEnterEvent()

void QGraphicsProxyWidget::dragEnterEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1058 of file qgraphicsproxywidget.cpp.

1059 {
1060 #ifdef QT_NO_DRAGANDDROP
1061  Q_UNUSED(event);
1062 #else
1064  if (!d->widget)
1065  return;
1066 
1067  QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers());
1068  proxyDragEnter.setAccepted(event->isAccepted());
1069  QApplication::sendEvent(d->widget, &proxyDragEnter);
1070  event->setAccepted(proxyDragEnter.isAccepted());
1071  if (proxyDragEnter.isAccepted()) // we discard answerRect
1072  event->setDropAction(proxyDragEnter.dropAction());
1073 #endif
1074 }
double d
Definition: qnumeric_p.h:62
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
bool isAccepted() const
Definition: qcoreevent.h:307
void setDropAction(Qt::DropAction action)
This function lets the receiver of the drop set the drop action that was performed to action...
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QPointF pos() const
Returns the mouse position of the event relative to the view that sent the event. ...

◆ dragLeaveEvent()

void QGraphicsProxyWidget::dragLeaveEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1078 of file qgraphicsproxywidget.cpp.

1079 {
1080  Q_UNUSED(event);
1081 #ifndef QT_NO_DRAGANDDROP
1083  if (!d->widget || !d->dragDropWidget)
1084  return;
1085  QDragLeaveEvent proxyDragLeave;
1086  QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
1087  d->dragDropWidget = 0;
1088 #endif
1089 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ dragMoveEvent()

void QGraphicsProxyWidget::dragMoveEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1094 of file qgraphicsproxywidget.cpp.

1095 {
1096 #ifdef QT_NO_DRAGANDDROP
1097  Q_UNUSED(event);
1098 #else
1100  if (!d->widget)
1101  return;
1102  QPointF p = event->pos();
1103  event->ignore();
1104  QPointer<QWidget> subWidget = d->widget->childAt(p.toPoint());
1105  QPointer<QWidget> receiver = subWidget ? subWidget : d->widget;
1106  bool eventDelivered = false;
1107  for (; receiver; receiver = receiver->parentWidget()) {
1108  if (!receiver->isEnabled() || !receiver->acceptDrops())
1109  continue;
1110  // Map event position from us to the receiver
1111  QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
1112  if (receiver != d->dragDropWidget) {
1113  // Try to enter before we leave
1114  QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
1115  dragEnter.setDropAction(event->proposedAction());
1116  QApplication::sendEvent(receiver, &dragEnter);
1117  event->setAccepted(dragEnter.isAccepted());
1118  event->setDropAction(dragEnter.dropAction());
1119  if (!event->isAccepted()) {
1120  // propagate to the parent widget
1121  continue;
1122  }
1123 
1124  d->lastDropAction = event->dropAction();
1125 
1126  if (d->dragDropWidget) {
1127  QDragLeaveEvent dragLeave;
1128  QApplication::sendEvent(d->dragDropWidget, &dragLeave);
1129  }
1130  d->dragDropWidget = receiver;
1131  }
1132 
1133  QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
1134  event->setDropAction(d->lastDropAction);
1135  QApplication::sendEvent(receiver, &dragMove);
1136  event->setAccepted(dragMove.isAccepted());
1137  event->setDropAction(dragMove.dropAction());
1138  if (event->isAccepted())
1139  d->lastDropAction = event->dropAction();
1140  eventDelivered = true;
1141  break;
1142  }
1143 
1144  if (!eventDelivered) {
1145  if (d->dragDropWidget) {
1146  // Leave the last drag drop item
1147  QDragLeaveEvent dragLeave;
1148  QApplication::sendEvent(d->dragDropWidget, &dragLeave);
1149  d->dragDropWidget = 0;
1150  }
1151  // Propagate
1152  event->setDropAction(Qt::IgnoreAction);
1153  }
1154 #endif
1155 }
Qt::DropAction dropAction() const
Returns the action that was performed in this drag and drop.
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void setDropAction(Qt::DropAction action)
Sets the action to be performed on the data by the target.
Definition: qevent.cpp:2746
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
Definition: qevent.h:530
#define Q_D(Class)
Definition: qglobal.h:2482
bool isAccepted() const
Definition: qcoreevent.h:307
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
bool acceptDrops
whether drop events are enabled for this widget
Definition: qwidget.h:197
bool isEnabled() const
Definition: qwidget.h:948
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
Qt::DropAction proposedAction() const
Returns the drop action that is proposed, i.e., preferred.
Qt::DropActions possibleActions() const
Returns the possible drop actions that the drag and drop can result in.
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ dropEvent()

void QGraphicsProxyWidget::dropEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1160 of file qgraphicsproxywidget.cpp.

1161 {
1162 #ifdef QT_NO_DRAGANDDROP
1163  Q_UNUSED(event);
1164 #else
1166  if (d->widget && d->dragDropWidget) {
1167  QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint();
1168  QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
1169  QApplication::sendEvent(d->dragDropWidget, &dropEvent);
1170  event->setAccepted(dropEvent.isAccepted());
1171  d->dragDropWidget = 0;
1172  }
1173 #endif
1174 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
Qt::DropActions possibleActions() const
Returns the possible drop actions that the drag and drop can result in.
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void dropEvent(QGraphicsSceneDragDropEvent *event)
Reimplemented Function
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QPointF pos() const
Returns the mouse position of the event relative to the view that sent the event. ...

◆ event()

bool QGraphicsProxyWidget::event ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 838 of file qgraphicsproxywidget.cpp.

839 {
841  if (!d->widget)
842  return QGraphicsWidget::event(event);
843 
844  switch (event->type()) {
845  case QEvent::StyleChange:
846  // Propagate style changes to the embedded widget.
847  if (!d->styleChangeMode) {
849  d->widget->setStyle(style());
850  d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
851  }
852  break;
853  case QEvent::FontChange: {
854  // Propagate to widget.
855  QWidgetPrivate *wd = d->widget->d_func();
856  int mask = d->font.resolve() | d->inheritedFontResolveMask;
857  wd->inheritedFontResolveMask = mask;
858  wd->resolveFont();
859  break;
860  }
861  case QEvent::PaletteChange: {
862  // Propagate to widget.
863  QWidgetPrivate *wd = d->widget->d_func();
864  int mask = d->palette.resolve() | d->inheritedPaletteResolveMask;
865  wd->inheritedPaletteResolveMask = mask;
866  wd->resolvePalette();
867  break;
868  }
869  case QEvent::InputMethod: {
870  // Forward input method events if the focus widget enables
871  // input methods.
872  // ### Qt 4.5: this code must also go into a reimplementation
873  // of inputMethodEvent().
874  QWidget *focusWidget = d->widget->focusWidget();
875  if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
876  QApplication::sendEvent(focusWidget, event);
877  break;
878  }
880  QWidget *focusWidget = d->widget->focusWidget();
881  while (focusWidget) {
882  QApplication::sendEvent(focusWidget, event);
883  if (event->isAccepted())
884  return true;
885  focusWidget = focusWidget->parentWidget();
886  }
887  return false;
888  }
889  case QEvent::KeyPress: {
890  QKeyEvent *k = static_cast<QKeyEvent *>(event);
891  if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
892  if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
893  QWidget *focusWidget = d->widget->focusWidget();
894  while (focusWidget) {
895  bool res = QApplication::sendEvent(focusWidget, event);
896  if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) {
897  event->accept();
898  break;
899  }
900  focusWidget = focusWidget->parentWidget();
901  }
902  return true;
903  }
904  }
905  break;
906  }
907 #ifndef QT_NO_TOOLTIP
909  // Propagate the help event (for tooltip) to the widget under mouse
910  if (d->lastWidgetUnderMouse) {
912  QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
913  QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
914  QApplication::sendEvent(d->lastWidgetUnderMouse, &e);
915  event->setAccepted(e.isAccepted());
916  return e.isAccepted();
917  }
918  break;
919  }
920  case QEvent::ToolTipChange: {
921  // Propagate tooltip change to the widget
922  if (!d->tooltipChangeMode) {
924  d->widget->setToolTip(toolTip());
925  d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
926  }
927  break;
928  }
929 #endif
930  default:
931  break;
932  }
933  return QGraphicsWidget::event(event);
934 }
double d
Definition: qnumeric_p.h:62
QGraphicsWidget * focusWidget() const
If this widget, a child or descendant of this widget currently has input focus, this function will re...
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QPointF scenePos() const
Returns the position of the mouse cursor in scene coordinates at the moment the help event was sent...
The QKeyEvent class describes a key event.
Definition: qevent.h:224
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void resolvePalette()
Determine which palette is inherited from this widget&#39;s ancestors and QApplication::palette, resolve this against this widget&#39;s palette (attributes from the inherited palette are copied over this widget&#39;s palette).
Definition: qwidget.cpp:4927
QPointF pos() const
Returns the position of the item in parent coordinates.
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
bool isAccepted() const
Definition: qcoreevent.h:307
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the help event was sent...
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item&#39;s scene&#39;s coordinate system, to this item&#39;s coordinate sy...
uint inheritedPaletteResolveMask
Definition: qwidget_p.h:743
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
bool event(QEvent *event)
Handles the event.
QString toolTip() const
Returns the item&#39;s tool tip, or an empty QString if no tool tip has been set.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
uint inheritedFontResolveMask
Definition: qwidget_p.h:742
void resolveFont()
Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over).
Definition: qwidget.cpp:5074
bool event(QEvent *event)
Reimplemented Function
QStyle * style() const
Returns a pointer to the widget&#39;s style.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586

◆ eventFilter()

bool QGraphicsProxyWidget::eventFilter ( QObject object,
QEvent event 
)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 939 of file qgraphicsproxywidget.cpp.

940 {
942 
943  if (object == d->widget) {
944  switch (event->type()) {
946  updateGeometry();
947  break;
948  case QEvent::Resize:
949  // If the widget resizes itself, we resize the proxy too.
950  // Prevent feed-back by checking the geometry change mode.
951  if (!d->sizeChangeMode)
952  d->updateProxyGeometryFromWidget();
953  break;
954  case QEvent::Move:
955  // If the widget moves itself, we move the proxy too. Prevent
956  // feed-back by checking the geometry change mode.
957  if (!d->posChangeMode)
958  d->updateProxyGeometryFromWidget();
959  break;
960  case QEvent::Hide:
961  case QEvent::Show:
962  // If the widget toggles its visible state, the proxy will follow.
963  if (!d->visibleChangeMode) {
965  setVisible(event->type() == QEvent::Show);
966  d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
967  }
968  break;
970  // If the widget toggles its enabled state, the proxy will follow.
971  if (!d->enabledChangeMode) {
973  setEnabled(d->widget->isEnabled());
974  d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
975  }
976  break;
977  case QEvent::StyleChange:
978  // Propagate style changes to the proxy.
979  if (!d->styleChangeMode) {
981  setStyle(d->widget->style());
982  d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
983  }
984  break;
985 #ifndef QT_NO_TOOLTIP
987  // Propagate tooltip change to the proxy.
988  if (!d->tooltipChangeMode) {
990  setToolTip(d->widget->toolTip());
991  d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
992  }
993  break;
994 #endif
995  default:
996  break;
997  }
998  }
999  return QGraphicsWidget::eventFilter(object, event);
1000 }
double d
Definition: qnumeric_p.h:62
void setStyle(QStyle *style)
Sets the widget&#39;s style to style.
void setToolTip(const QString &toolTip)
Sets the item&#39;s tool tip to toolTip.
#define Q_D(Class)
Definition: qglobal.h:2482
void setVisible(bool visible)
If visible is true, the item is made visible.
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
void setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void updateGeometry()
If this widget is currently managed by a layout, this function notifies the layout that the widget&#39;s ...

◆ focusInEvent()

void QGraphicsProxyWidget::focusInEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1353 of file qgraphicsproxywidget.cpp.

1354 {
1355 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1356  qDebug() << "QGraphicsProxyWidget::focusInEvent";
1357 #endif
1359 
1360  if (d->focusFromWidgetToProxy) {
1361  // Prevent recursion when the proxy autogains focus through the
1362  // embedded widget calling setFocus(). ### Could be done with event
1363  // filter on FocusIn instead?
1364  return;
1365  }
1366 
1367  d->proxyIsGivingFocus = true;
1368 
1369  switch (event->reason()) {
1370  case Qt::TabFocusReason: {
1371  if (QWidget *focusChild = d->findFocusChild(0, true))
1372  focusChild->setFocus(event->reason());
1373  break;
1374  }
1376  if (QWidget *focusChild = d->findFocusChild(0, false))
1377  focusChild->setFocus(event->reason());
1378  break;
1379  default:
1380  if (d->widget && d->widget->focusWidget()) {
1381  d->widget->focusWidget()->setFocus(event->reason());
1382  }
1383  break;
1384  }
1385 
1386  d->proxyIsGivingFocus = false;
1387 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
Qt::FocusReason reason()
Definition: qevent.cpp:1197

◆ focusNextPrevChild()

bool QGraphicsProxyWidget::focusNextPrevChild ( bool  next)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1409 of file qgraphicsproxywidget.cpp.

1410 {
1412  if (!d->widget || !d->scene)
1414 
1416  QWidget *lastFocusChild = d->widget->focusWidget();
1417  if (QWidget *newFocusChild = d->findFocusChild(lastFocusChild, next)) {
1418  newFocusChild->setFocus(reason);
1419  return true;
1420  }
1421 
1423 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
virtual bool focusNextPrevChild(bool 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.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
FocusReason
Definition: qnamespace.h:1521

◆ focusOutEvent()

void QGraphicsProxyWidget::focusOutEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1392 of file qgraphicsproxywidget.cpp.

1393 {
1394 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1395  qDebug() << "QGraphicsProxyWidget::focusOutEvent";
1396 #endif
1398  if (d->widget) {
1399  // We need to explicitly remove subfocus from the embedded widget's
1400  // focus widget.
1401  if (QWidget *focusWidget = d->widget->focusWidget())
1402  d->removeSubFocusHelper(focusWidget, event->reason());
1403  }
1404 }
double d
Definition: qnumeric_p.h:62
QGraphicsWidget * focusWidget() const
If this widget, a child or descendant of this widget currently has input focus, this function will re...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
Qt::FocusReason reason()
Definition: qevent.cpp:1197

◆ grabMouseEvent()

void QGraphicsProxyWidget::grabMouseEvent ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1224 of file qgraphicsproxywidget.cpp.

1225 {
1226  Q_UNUSED(event);
1227 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ hideEvent()

void QGraphicsProxyWidget::hideEvent ( QHideEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1013 of file qgraphicsproxywidget.cpp.

1014 {
1015  Q_UNUSED(event);
1016 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ hoverEnterEvent()

void QGraphicsProxyWidget::hoverEnterEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1180 of file qgraphicsproxywidget.cpp.

1181 {
1182  Q_UNUSED(event);
1183 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ hoverLeaveEvent()

void QGraphicsProxyWidget::hoverLeaveEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1188 of file qgraphicsproxywidget.cpp.

1189 {
1190  Q_UNUSED(event);
1192  // If hoverMove was compressed away, make sure we update properly here.
1193  if (d->lastWidgetUnderMouse) {
1194  QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
1195  d->lastWidgetUnderMouse = 0;
1196  }
1197 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ hoverMoveEvent()

void QGraphicsProxyWidget::hoverMoveEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1202 of file qgraphicsproxywidget.cpp.

1203 {
1205 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1206  qDebug() << "QGraphicsProxyWidget::hoverMoveEvent";
1207 #endif
1208  // Ignore events on the window frame.
1209  if (!d->widget || !rect().contains(event->pos())) {
1210  if (d->lastWidgetUnderMouse) {
1211  QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
1212  d->lastWidgetUnderMouse = 0;
1213  }
1214  return;
1215  }
1216 
1217  d->embeddedMouseGrabber = 0;
1218  d->sendWidgetMouseEvent(event);
1219 }
double d
Definition: qnumeric_p.h:62
QRectF rect() const
Returns the item&#39;s local rect as a QRectF.
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)

◆ itemChange()

QVariant QGraphicsProxyWidget::itemChange ( GraphicsItemChange  change,
const QVariant value 
)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 788 of file qgraphicsproxywidget.cpp.

790 {
792 
793  switch (change) {
794  case ItemPositionChange:
795  // The item's position is either changed directly on the proxy, in
796  // which case the position change should propagate to the widget,
797  // otherwise it happens as a side effect when filtering QEvent::Move.
798  if (!d->posChangeMode)
800  break;
802  // Move the internal widget if we're in widget-to-proxy
803  // mode. Otherwise the widget has already moved.
804  if (d->widget && d->posChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
805  d->widget->move(value.toPoint());
807  d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
808  break;
809  case ItemVisibleChange:
810  if (!d->visibleChangeMode)
812  break;
814  if (d->widget && d->visibleChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
815  d->widget->setVisible(isVisible());
816  if (d->visibleChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
817  d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
818  break;
819  case ItemEnabledChange:
820  if (!d->enabledChangeMode)
822  break;
824  if (d->widget && d->enabledChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
825  d->widget->setEnabled(isEnabled());
826  if (d->enabledChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
827  d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
828  break;
829  default:
830  break;
831  }
832  return QGraphicsWidget::itemChange(change, value);
833 }
double d
Definition: qnumeric_p.h:62
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
#define Q_D(Class)
Definition: qglobal.h:2482
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
QGraphicsWidget uses the base implementation of this function to catch and deliver events related to ...
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
Definition: qvariant.cpp:2400

◆ keyPressEvent()

void QGraphicsProxyWidget::keyPressEvent ( QKeyEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1329 of file qgraphicsproxywidget.cpp.

1330 {
1332 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1333  qDebug() << "QGraphicsProxyWidget::keyPressEvent";
1334 #endif
1335  d->sendWidgetKeyEvent(event);
1336 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ keyReleaseEvent()

void QGraphicsProxyWidget::keyReleaseEvent ( QKeyEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1341 of file qgraphicsproxywidget.cpp.

1342 {
1344 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1345  qDebug() << "QGraphicsProxyWidget::keyReleaseEvent";
1346 #endif
1347  d->sendWidgetKeyEvent(event);
1348 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ mouseDoubleClickEvent()

void QGraphicsProxyWidget::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1266 of file qgraphicsproxywidget.cpp.

1267 {
1269 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1270  qDebug() << "QGraphicsProxyWidget::mouseDoubleClickEvent";
1271 #endif
1272  d->sendWidgetMouseEvent(event);
1273 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ mouseMoveEvent()

void QGraphicsProxyWidget::mouseMoveEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1242 of file qgraphicsproxywidget.cpp.

1243 {
1245 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1246  qDebug() << "QGraphicsProxyWidget::mouseMoveEvent";
1247 #endif
1248  d->sendWidgetMouseEvent(event);
1249 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ mousePressEvent()

void QGraphicsProxyWidget::mousePressEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1254 of file qgraphicsproxywidget.cpp.

1255 {
1257 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1258  qDebug() << "QGraphicsProxyWidget::mousePressEvent";
1259 #endif
1260  d->sendWidgetMouseEvent(event);
1261 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ mouseReleaseEvent()

void QGraphicsProxyWidget::mouseReleaseEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1317 of file qgraphicsproxywidget.cpp.

1318 {
1320 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1321  qDebug() << "QGraphicsProxyWidget::mouseReleaseEvent";
1322 #endif
1323  d->sendWidgetMouseEvent(event);
1324 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ newProxyWidget

QGraphicsProxyWidget * QGraphicsProxyWidget::newProxyWidget ( const QWidget child)
protectedslot
Since
4.5

Creates a proxy widget for the given child of the widget contained in this proxy.

You should not call this function directly; use QGraphicsProxyWidget::createProxyForChildWidget() instead.

This function is a fake virtual slot that you can reimplement in your subclass in order to control how new proxy widgets are created. The default implementation returns a proxy created with the QGraphicsProxyWidget() constructor with this proxy widget as the parent.

See also
createProxyForChildWidget()

Definition at line 1569 of file qgraphicsproxywidget.cpp.

1570 {
1571  return new QGraphicsProxyWidget(this);
1572 }
QGraphicsProxyWidget(QGraphicsItem *parent=0, Qt::WindowFlags wFlags=0)
Constructs a new QGraphicsProxy widget.

◆ paint()

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

Reimplemented Function

Implements QGraphicsItem.

Definition at line 1479 of file qgraphicsproxywidget.cpp.

1480 {
1482  Q_UNUSED(widget);
1483  if (!d->widget || !d->widget->isVisible())
1484  return;
1485 
1486  // Filter out repaints on the window frame.
1487  const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
1488  if (exposedWidgetRect.isEmpty())
1489  return;
1490 
1491  // Disable QPainter's default pen being cosmetic. This allows widgets and
1492  // styles to follow Qt's existing defaults without getting ugly cosmetic
1493  // lines when scaled.
1494  bool restore = !(painter->renderHints() & QPainter::NonCosmeticDefaultPen);
1496 
1497  d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
1498 
1499  // Restore the render hints if necessary.
1500  if (restore)
1502 }
double d
Definition: qnumeric_p.h:62
QRectF rect() const
Returns the item&#39;s local rect as a QRectF.
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
void setRenderHints(RenderHints hints, bool on=true)
Sets the given render hints on the painter if on is true; otherwise clears the render hints...
Definition: qpainter.cpp:7649
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675
QRectF exposedRect
the exposed rectangle, in item coordinates
Definition: qstyleoption.h:873
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ resizeEvent()

void QGraphicsProxyWidget::resizeEvent ( QGraphicsSceneResizeEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1466 of file qgraphicsproxywidget.cpp.

1467 {
1469  if (d->widget) {
1470  if (d->sizeChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
1471  d->widget->resize(event->newSize().toSize());
1472  }
1474 }
double d
Definition: qnumeric_p.h:62
QSize toSize() const
Returns an integer based copy of this size.
Definition: qsize.h:355
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resizeEvent(QGraphicsSceneResizeEvent *event)
This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i...
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QSizeF newSize() const
Returns the new size (i.e., the current size).

◆ setGeometry()

void QGraphicsProxyWidget::setGeometry ( const QRectF rect)
virtual

Reimplemented Function

Reimplemented from QGraphicsLayoutItem.

Definition at line 770 of file qgraphicsproxywidget.cpp.

771 {
773  bool proxyResizesWidget = !d->posChangeMode && !d->sizeChangeMode;
774  if (proxyResizesWidget) {
777  }
779  if (proxyResizesWidget) {
780  d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
781  d->sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
782  }
783 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ setWidget()

void QGraphicsProxyWidget::setWidget ( QWidget widget)

Embeds widget into this proxy widget.

The embedded widget must reside exclusively either inside or outside of Graphics View. You cannot embed a widget as long as it is is visible elsewhere in the UI, at the same time.

widget must be a top-level widget whose parent is 0.

When the widget is embedded, its state (e.g., visible, enabled, geometry, size hints) is copied into the proxy widget. If the embedded widget is explicitly hidden or disabled, the proxy widget will become explicitly hidden or disabled after embedding is complete. The class documentation has a full overview over the shared state.

QGraphicsProxyWidget's window flags determine whether the widget, after embedding, will be given window decorations or not.

After this function returns, QGraphicsProxyWidget will keep its state synchronized with that of widget whenever possible.

If a widget is already embedded by this proxy when this function is called, that widget will first be automatically unembedded. Passing 0 for the widget argument will only unembed the widget, and the ownership of the currently embedded widget will be passed on to the caller. Every child widget that are embedded will also be embedded and their proxy widget destroyed.

Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller cannot be embedded. Examples are QGLWidget and QAxWidget.

See also
widget()

Definition at line 597 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsScene::addWidget(), createProxyForChildWidget(), and QGraphicsProxyWidgetPrivate::setWidget_helper().

598 {
600  d->setWidget_helper(widget, true);
601 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ showEvent()

void QGraphicsProxyWidget::showEvent ( QShowEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1005 of file qgraphicsproxywidget.cpp.

1006 {
1007  Q_UNUSED(event);
1008 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ sizeHint()

QSizeF QGraphicsProxyWidget::sizeHint ( Qt::SizeHint  which,
const QSizeF constraint = QSizeF() 
) const
protectedvirtual

Reimplemented Function

Implements QGraphicsLayoutItem.

Definition at line 1428 of file qgraphicsproxywidget.cpp.

1429 {
1430  Q_D(const QGraphicsProxyWidget);
1431  if (!d->widget)
1432  return QGraphicsWidget::sizeHint(which, constraint);
1433 
1434  QSizeF sh;
1435  switch (which) {
1436  case Qt::PreferredSize:
1437  if (QLayout *l = d->widget->layout())
1438  sh = l->sizeHint();
1439  else
1440  sh = d->widget->sizeHint();
1441  break;
1442  case Qt::MinimumSize:
1443  if (QLayout *l = d->widget->layout())
1444  sh = l->minimumSize();
1445  else
1446  sh = d->widget->minimumSizeHint();
1447  break;
1448  case Qt::MaximumSize:
1449  if (QLayout *l = d->widget->layout())
1450  sh = l->maximumSize();
1451  else
1453  break;
1454  case Qt::MinimumDescent:
1455  sh = constraint;
1456  break;
1457  default:
1458  break;
1459  }
1460  return sh;
1461 }
double d
Definition: qnumeric_p.h:62
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
#define Q_D(Class)
Definition: qglobal.h:2482
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Reimplemented Function
QFactoryLoader * l

◆ subWidgetRect()

QRectF QGraphicsProxyWidget::subWidgetRect ( const QWidget widget) const

Returns the rectangle for widget, which must be a descendant of widget(), or widget() itself, in this proxy item's local coordinates.

If no widget is embedded, widget is 0, or widget is not a descendant of the embedded widget, this function returns an empty QRectF.

See also
widget()

Definition at line 757 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget().

758 {
759  Q_D(const QGraphicsProxyWidget);
760  if (!widget || !d->widget)
761  return QRectF();
762  if (d->widget == widget || d->widget->isAncestorOf(widget))
763  return QRectF(widget->mapTo(d->widget, QPoint(0, 0)), widget->size());
764  return QRectF();
765 }
double d
Definition: qnumeric_p.h:62
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
#define Q_D(Class)
Definition: qglobal.h:2482
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ type()

int QGraphicsProxyWidget::type ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1507 of file qgraphicsproxywidget.cpp.

1508 {
1509  return Type;
1510 }

◆ ungrabMouseEvent()

void QGraphicsProxyWidget::ungrabMouseEvent ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsWidget.

Definition at line 1232 of file qgraphicsproxywidget.cpp.

1233 {
1235  Q_UNUSED(event);
1236  d->embeddedMouseGrabber = 0;
1237 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ wheelEvent()

void QGraphicsProxyWidget::wheelEvent ( QGraphicsSceneWheelEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1279 of file qgraphicsproxywidget.cpp.

1280 {
1282 #ifdef GRAPHICSPROXYWIDGET_DEBUG
1283  qDebug() << "QGraphicsProxyWidget::wheelEvent";
1284 #endif
1285  if (!d->widget)
1286  return;
1287 
1288  QPointF pos = event->pos();
1289  QPointer<QWidget> receiver = d->widget->childAt(pos.toPoint());
1290  if (!receiver)
1291  receiver = d->widget;
1292 
1293  // Map event position from us to the receiver
1294  pos = d->mapToReceiver(pos, receiver);
1295 
1296  // Send mouse event.
1297  QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(),
1298  event->buttons(), event->modifiers(), event->orientation());
1299  QPointer<QWidget> focusWidget = d->widget->focusWidget();
1300  extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
1301  qt_sendSpontaneousEvent(receiver, &wheelEvent);
1302  event->setAccepted(wheelEvent.isAccepted());
1303 
1304  // ### Remove, this should be done by proper focusIn/focusOut events.
1305  if (focusWidget && !focusWidget->hasFocus()) {
1306  focusWidget->update();
1307  focusWidget = d->widget->focusWidget();
1308  if (focusWidget && focusWidget->hasFocus())
1309  focusWidget->update();
1310  }
1311 }
double d
Definition: qnumeric_p.h:62
QGraphicsWidget * focusWidget() const
If this widget, a child or descendant of this widget currently has input focus, this function will re...
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF pos() const
Returns the position of the item in parent coordinates.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
void wheelEvent(QGraphicsSceneWheelEvent *event)
Reimplemented Function
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ widget()

QWidget * QGraphicsProxyWidget::widget ( ) const

Returns a pointer to the embedded widget.

See also
setWidget()

Definition at line 742 of file qgraphicsproxywidget.cpp.

Referenced by _q_paintItem(), QGraphicsScenePrivate::drawItemHelper(), QMotifStyle::event(), QMacStyle::event(), QGraphicsWidget::paintWindowFrame(), QGraphicsProxyWidgetPrivate::setWidget_helper(), and QGraphicsViewPrivate::updateInputMethodSensitivity().

743 {
744  Q_D(const QGraphicsProxyWidget);
745  return d->widget;
746 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

Friends and Related Functions

◆ QGraphicsItem

friend class QGraphicsItem
friend

Definition at line 137 of file qgraphicsproxywidget.h.

◆ QWidget

friend class QWidget
friend

Definition at line 135 of file qgraphicsproxywidget.h.

◆ QWidgetPrivate

friend class QWidgetPrivate
friend

Definition at line 136 of file qgraphicsproxywidget.h.


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