Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Static Public Functions | Protected Functions | Properties | Friends | List of all members
QGraphicsWidget Class Reference

The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene. More...

#include <qgraphicswidget.h>

Inheritance diagram for QGraphicsWidget:
QGraphicsObject QGraphicsLayoutItem QObject QGraphicsItem QGraphicsProxyWidget

Public Types

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 Slots

bool close ()
 Call this function to close the widget. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

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...
 

Public Functions

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...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. 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...
 

Static Public Functions

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)
 

Protected Functions

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...
 
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. 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 grabMouseEvent (QEvent *event)
 This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::GrabMouse events. More...
 
virtual void hideEvent (QHideEvent *event)
 This event handler, for Hide events, is delivered after the widget has been hidden, for example, setVisible(false) has been called for the widget or one of its ancestors when the widget was previously shown. More...
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function 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...
 
virtual void resizeEvent (QGraphicsSceneResizeEvent *event)
 This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i.e., its local size has changed). More...
 
bool sceneEvent (QEvent *event)
 QGraphicsWidget's implementation of sceneEvent() simply passes event to QGraphicsWidget::event(). More...
 
virtual void showEvent (QShowEvent *event)
 This event handler, for Show events, is delivered before the widget has been shown, for example, setVisible(true) has been called for the widget or one of its ancestors when the widget was previously hidden. 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...
 
virtual void ungrabMouseEvent (QEvent *event)
 This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::UngrabMouse 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 void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 This event handler can be reimplemented in a subclass to process context menu events. More...
 
virtual void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drag enter events for this item. More...
 
virtual void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drag leave events for this item. More...
 
virtual void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drag move events for this item. More...
 
virtual void dropEvent (QGraphicsSceneDragDropEvent *event)
 This event handler, for event event, can be reimplemented to receive drop events for this item. More...
 
virtual 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 hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 This event handler, for event event, can be reimplemented to receive hover enter events for this item. More...
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 This event handler, for event event, can be reimplemented to receive input method events for this item. More...
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 This method is only relevant for input items. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 This event handler, for event event, can be reimplemented to receive key press events for this item. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 This event handler, for event event, can be reimplemented to receive key release events for this item. More...
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse doubleclick events for this item. More...
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse move events for this item. More...
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse press events for this item. More...
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 This event handler, for event event, can be reimplemented to receive mouse release events for this item. More...
 
void prepareGeometryChange ()
 Prepares the item for a geometry change. More...
 
 QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
 
void removeFromIndex ()
 Removes this item from the scene's index. More...
 
virtual bool 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...
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
 This event handler, for event event, can be reimplemented to receive wheel events for this item. 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...
 

Properties

bool autoFillBackground
 whether the widget background is filled automatically More...
 
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus More...
 
QFont font
 the widgets' font More...
 
QRectF geometry
 the geometry of the widget More...
 
QGraphicsLayoutlayout
 The layout of the widget. More...
 
Qt::LayoutDirection layoutDirection
 the layout direction for this widget. More...
 
QSizeF maximumSize
 the maximum size of the widget More...
 
QSizeF minimumSize
 the minimum size of the widget More...
 
QPalette palette
 the widget's palette More...
 
QSizeF preferredSize
 the preferred size of the widget More...
 
QSizeF size
 the size of the widget More...
 
QSizePolicy sizePolicy
 the size policy for the widget More...
 
Qt::WindowFlags windowFlags
 the widget's window flags More...
 
QString windowTitle
 This property holds the window title (caption). More...
 

Friends

class QApplication
 
class QGraphicsItem
 
class QGraphicsItemPrivate
 
class QGraphicsLayout
 
class QGraphicsScene
 
class QGraphicsScenePrivate
 
class QGraphicsView
 
class QWidget
 

Additional Inherited Members

- 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 Slots inherited from QGraphicsObject
void updateMicroFocus ()
 Updates the item's micro focus. 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 QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

Since
4.4

QGraphicsWidget is an extended base item that provides extra functionality over QGraphicsItem. It is similar to QWidget in many ways:

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

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

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

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

Noticeable differences between QGraphicsWidget and QWidget are:

QGraphicsWidget QWidget
Coordinates and geometry are defined with qreals (doubles or floats, depending on the platform). QWidget uses integer geometry (QPoint, QRect).
The widget is already visible by default; you do not have to call show() to display the widget. QWidget is hidden by default until you call show().
A subset of widget attributes are supported. All widget attributes are supported.
A top-level item's style defaults to QGraphicsScene::style A top-level widget's style defaults to QApplication::style
Graphics View provides a custom drag and drop framework, different from QWidget. Standard drag and drop framework.
Widget items do not support modality. Full modality support.

QGraphicsWidget supports a subset of Qt's widget attributes, (Qt::WidgetAttribute), as shown in the table below. Any attributes not listed in this table are unsupported, or otherwise unused.

Widget Attribute Usage
Qt::WA_SetLayoutDirection Set by setLayoutDirection(), cleared by unsetLayoutDirection(). You can test this attribute to check if the widget has been explicitly assigned a layoutDirection. If the attribute is not set, the layoutDirection() is inherited.
Qt::WA_RightToLeft Toggled by setLayoutDirection(). Inherited from the parent/scene. If set, the widget's layout will order horizontally arranged widgets from right to left.
Qt::WA_SetStyle Set and cleared by setStyle(). If this attribute is set, the widget has been explicitly assigned a style. If it is unset, the widget will use the scene's or the application's style.
Qt::WA_Resized Set by setGeometry() and resize().
Qt::WA_SetPalette Set by setPalette().
Qt::WA_SetFont Set by setFont().
Qt::WA_WindowPropagation Enables propagation to window widgets.

Although QGraphicsWidget inherits from both QObject and QGraphicsItem, you should use the functions provided by QGraphicsItem, not QObject, to manage the relationships between parent and child items. These functions control the stacking order of items as well as their ownership.

Note
The QObject::parent() should always return 0 for QGraphicsWidgets, but this policy is not strictly defined.
See also
QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}

Definition at line 69 of file qgraphicswidget.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 161 of file qgraphicswidget.h.

161  {
162  Type = 11
163  };

Constructors and Destructors

◆ QGraphicsWidget() [1/2]

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

Constructs a QGraphicsWidget instance.

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

Definition at line 178 of file qgraphicswidget.cpp.

180 {
182  d->init(parent, wFlags);
183 }
double d
Definition: qnumeric_p.h:62
QGraphicsObject(QGraphicsItem *parent=0)
Constructs a QGraphicsObject with parent.
#define Q_D(Class)
Definition: qglobal.h:2482
QGraphicsLayoutItem(QGraphicsLayoutItem *parent=0, bool isLayout=false)
Constructs the QGraphicsLayoutItem object.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ ~QGraphicsWidget()

QGraphicsWidget::~QGraphicsWidget ( )

Destroys the QGraphicsWidget instance.

Definition at line 236 of file qgraphicswidget.cpp.

237 {
239 #ifndef QT_NO_ACTION
240  // Remove all actions from this widget
241  for (int i = 0; i < d->actions.size(); ++i) {
242  QActionPrivate *apriv = d->actions.at(i)->d_func();
243  apriv->graphicsWidgets.removeAll(this);
244  }
245  d->actions.clear();
246 #endif
247 
248  if (QGraphicsScene *scn = scene()) {
249  QGraphicsScenePrivate *sceneD = scn->d_func();
250  if (sceneD->tabFocusFirst == this)
251  sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
252  }
253  d->focusPrev->d_func()->focusNext = d->focusNext;
254  d->focusNext->d_func()->focusPrev = d->focusPrev;
255 
256  // Play it really safe
257  d->focusNext = this;
258  d->focusPrev = this;
259 
260  clearFocus();
261 
262  //we check if we have a layout previously
263  if (d->layout) {
264  QGraphicsLayout *temp = d->layout;
265  foreach (QGraphicsItem * item, childItems()) {
266  // In case of a custom layout which doesn't remove and delete items, we ensure that
267  // the parent layout item does not point to the deleted layout. This code is here to
268  // avoid regression from 4.4 to 4.5, because according to 4.5 docs it is not really needed.
269  if (item->isWidget()) {
270  QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
271  if (widget->parentLayoutItem() == d->layout)
272  widget->setParentLayoutItem(0);
273  }
274  }
275  d->layout = 0;
276  delete temp;
277  }
278 
279  // Remove this graphics widget from widgetStyles
280  widgetStyles()->setStyleForWidget(this, 0);
281 }
double d
Definition: qnumeric_p.h:62
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
QPointer< QWidget > widget
QList< QGraphicsItem * > childItems() const
Returns a list of this item&#39;s children.
void clearFocus()
Takes keyboard input focus from the item.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
void setParentLayoutItem(QGraphicsLayoutItem *parent)
Sets the parent of this QGraphicsLayoutItem to parent.
#define Q_D(Class)
Definition: qglobal.h:2482
QList< QGraphicsWidget * > graphicsWidgets
Definition: qaction_p.h:123
QGraphicsWidget * tabFocusFirst
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
bool isWidget() const
Returns true if this item is a widget (i.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ QGraphicsWidget() [2/2]

QGraphicsWidget::QGraphicsWidget ( QGraphicsWidgetPrivate dd,
QGraphicsItem parent,
QGraphicsScene scene,
Qt::WindowFlags  wFlags = 0 
)
protected

Constructs a new QGraphicsWidget, using dd as parent.

Warning
This function is not part of the public interface.

Definition at line 193 of file qgraphicswidget.cpp.

194  : QGraphicsObject(dd, 0, scene), QGraphicsLayoutItem(0, false)
195 {
197  d->init(parent, wFlags);
198 }
double d
Definition: qnumeric_p.h:62
QGraphicsObject(QGraphicsItem *parent=0)
Constructs a QGraphicsObject with parent.
#define Q_D(Class)
Definition: qglobal.h:2482
QGraphicsLayoutItem(QGraphicsLayoutItem *parent=0, bool isLayout=false)
Constructs the QGraphicsLayoutItem object.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

Functions

◆ actions()

QList< QAction * > QGraphicsWidget::actions ( ) const

Returns the (possibly empty) list of this widget's actions.

Since
4.5
See also
insertAction(), removeAction(), QWidget::actions(), QAction::associatedWidgets(), QAction::associatedGraphicsWidgets()

Definition at line 2177 of file qgraphicswidget.cpp.

2178 {
2179  Q_D(const QGraphicsWidget);
2180  return d->actions;
2181 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ addAction()

void QGraphicsWidget::addAction ( QAction action)

Appends the action action to this widget's list of actions.

Since
4.5

All QGraphicsWidgets have a list of QAction, however they can be represented graphically in many different ways. The default use of the QAction list (as returned by actions()) is to create a context QMenu.

A QGraphicsWidget should only have one of each action and adding an action it already has will not cause the same action to be in the widget twice.

See also
removeAction(), insertAction(), actions(), QWidget::addAction()

Definition at line 2056 of file qgraphicswidget.cpp.

2057 {
2058  insertAction(0, action);
2059 }
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget&#39;s list of actions, before the action before.

◆ addActions()

void QGraphicsWidget::addActions ( QList< QAction *>  actions)

Appends the actions actions to this widget's list of actions.

Since
4.5
See also
removeAction(), QMenu, addAction(), QWidget::addActions()

Definition at line 2071 of file qgraphicswidget.cpp.

2072 {
2073  for (int i = 0; i < actions.count(); ++i)
2074  insertAction(0, actions.at(i));
2075 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget&#39;s list of actions, before the action before.

◆ adjustSize()

void QGraphicsWidget::adjustSize ( )

Adjusts the size of the widget to its effective preferred size hint.

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

See also
effectiveSizeHint(), Qt::MinimumSize

Definition at line 892 of file qgraphicswidget.cpp.

Referenced by itemChange().

893 {
895  // What if sz is not valid?!
896  if (sz.isValid())
897  resize(sz);
898 }
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:281
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void resize(const QSizeF &size)

◆ autoFillBackground()

bool QGraphicsWidget::autoFillBackground ( ) const

Referenced by setPalette().

◆ boundingRect()

QRectF QGraphicsWidget::boundingRect ( ) const
virtual

Reimplemented Function

Implements QGraphicsItem.

Definition at line 2437 of file qgraphicswidget.cpp.

2438 {
2439  return windowFrameRect();
2440 }
QRectF windowFrameRect() const
Returns the widget&#39;s local rect including any window frame.

◆ changeEvent()

void QGraphicsWidget::changeEvent ( QEvent event)
protectedvirtual

This event handler can be reimplemented to handle state changes.

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

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

Definition at line 1526 of file qgraphicswidget.cpp.

Referenced by event().

1527 {
1529  switch (event->type()) {
1530  case QEvent::StyleChange:
1531  // ### Don't unset if the margins are explicitly set.
1533  if (d->layout)
1534  d->layout->invalidate();
1535  case QEvent::FontChange:
1536  update();
1537  updateGeometry();
1538  break;
1539  case QEvent::PaletteChange:
1540  update();
1541  break;
1542  case QEvent::ParentChange:
1543  d->resolveFont(d->inheritedFontResolveMask);
1544  d->resolvePalette(d->inheritedPaletteResolveMask);
1545  break;
1546  default:
1547  break;
1548  }
1549 }
double d
Definition: qnumeric_p.h:62
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
#define Q_D(Class)
Definition: qglobal.h:2482
void unsetWindowFrameMargins()
Resets the window frame margins to the default value, provided by the style.
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 ...
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ close

bool QGraphicsWidget::close ( )
slot

Call this function to close the widget.

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

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

Definition at line 2463 of file qgraphicswidget.cpp.

Referenced by QGraphicsItem::mousePressEvent().

2464 {
2466  QApplication::sendEvent(this, &closeEvent);
2467  if (!closeEvent.isAccepted()) {
2468  return false;
2469  }
2470  // hide
2471  if (isVisible()) {
2472  hide();
2473  }
2475  deleteLater();
2476  }
2477  return true;
2478 }
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
virtual void closeEvent(QCloseEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive widget close events...
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.
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
void hide()
Hides the item.
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364

◆ closeEvent()

void QGraphicsWidget::closeEvent ( QCloseEvent event)
protectedvirtual

This event handler, for event, can be reimplemented in a subclass to receive widget close events.

The default implementation accepts the event.

See also
close(), QCloseEvent

Definition at line 1558 of file qgraphicswidget.cpp.

Referenced by close(), and event().

1559 {
1560  event->accept();
1561 }

◆ event()

bool QGraphicsWidget::event ( QEvent event)
protectedvirtual

Handles the event.

Reimplemented Function

QGraphicsWidget handles the following events:

Event

Usage

Polish

Delivered to the widget some time after it has been shown.

GraphicsSceneMove

Delivered to the widget after its local position has changed.

GraphicsSceneResize

Delivered to the widget after its size has changed.

Show

Delivered to the widget before it has been shown.

Hide

Delivered to the widget after it has been hidden.

PaletteChange

Delivered to the widget after its palette has changed.

FontChange

Delivered to the widget after its font has changed.

EnabledChange

Delivered to the widget after its enabled state has changed.

StyleChange

Delivered to the widget after its style has changed.

LayoutDirectionChange

Delivered to the widget after its layout direction has changed.

ContentsRectChange

Delivered to the widget after its contents margins/ contents rect has changed.

Reimplemented from QObject.

Definition at line 1432 of file qgraphicswidget.cpp.

Referenced by QGraphicsProxyWidget::event(), itemChange(), setGeometry(), and setStyle().

1433 {
1435  // Forward the event to the layout first.
1436  if (d->layout)
1437  d->layout->widgetEvent(event);
1438 
1439  // Handle the event itself.
1440  switch (event->type()) {
1442  moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event));
1443  break;
1445  resizeEvent(static_cast<QGraphicsSceneResizeEvent *>(event));
1446  break;
1447  case QEvent::Show:
1448  showEvent(static_cast<QShowEvent *>(event));
1449  break;
1450  case QEvent::Hide:
1451  hideEvent(static_cast<QHideEvent *>(event));
1452  break;
1453  case QEvent::Polish:
1454  polishEvent();
1455  d->polished = true;
1456  if (!d->font.isCopyOf(QApplication::font()))
1457  d->updateFont(d->font);
1458  break;
1461  update();
1462  break;
1463  // Taken from QWidget::event
1465  case QEvent::EnabledChange:
1466  case QEvent::FontChange:
1467  case QEvent::StyleChange:
1468  case QEvent::PaletteChange:
1469  case QEvent::ParentChange:
1472  changeEvent(event);
1473  break;
1474  case QEvent::Close:
1475  closeEvent((QCloseEvent *)event);
1476  break;
1477  case QEvent::GrabMouse:
1478  grabMouseEvent(event);
1479  break;
1480  case QEvent::UngrabMouse:
1481  ungrabMouseEvent(event);
1482  break;
1483  case QEvent::GrabKeyboard:
1484  grabKeyboardEvent(event);
1485  break;
1487  ungrabKeyboardEvent(event);
1488  break;
1490  if (d->hasDecoration() && windowFrameEvent(event))
1491  return true;
1495  d->ensureWindowData();
1496  if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection)
1497  return windowFrameEvent(event);
1498  break;
1502  if (d->hasDecoration()) {
1503  windowFrameEvent(event);
1504  // Filter out hover events if they were sent to us only because of the
1505  // decoration (special case in QGraphicsScenePrivate::dispatchHoverEvent).
1506  if (!acceptsHoverEvents())
1507  return true;
1508  }
1509  break;
1510  default:
1511  break;
1512  }
1513  return QObject::event(event);
1514 }
double d
Definition: qnumeric_p.h:62
virtual void ungrabMouseEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
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.
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_D(Class)
Definition: qglobal.h:2482
virtual bool windowFrameEvent(QEvent *e)
This event handler, for event, receives events for the window frame if this widget is a window...
virtual void closeEvent(QCloseEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive widget close events...
static QFont font()
Returns the default application font.
virtual void resizeEvent(QGraphicsSceneResizeEvent *event)
This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i...
virtual void changeEvent(QEvent *event)
This event handler can be reimplemented to handle state changes.
virtual void grabKeyboardEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
virtual void moveEvent(QGraphicsSceneMoveEvent *event)
This event handler, for GraphicsSceneMove events, is delivered after the widget has moved (e...
virtual void grabMouseEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
virtual void ungrabKeyboardEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
bool acceptsHoverEvents() const
Call acceptHoverEvents() instead.
virtual void hideEvent(QHideEvent *event)
This event handler, for Hide events, is delivered after the widget has been hidden, for example, setVisible(false) has been called for the widget or one of its ancestors when the widget was previously shown.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
virtual void showEvent(QShowEvent *event)
This event handler, for Show events, is delivered before the widget has been shown, for example, setVisible(true) has been called for the widget or one of its ancestors when the widget was previously hidden.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ focusInEvent()

void QGraphicsWidget::focusInEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1566 of file qgraphicswidget.cpp.

1567 {
1568  Q_UNUSED(event);
1569  if (focusPolicy() != Qt::NoFocus)
1570  update();
1571 }
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
Qt::FocusPolicy focusPolicy() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ focusNextPrevChild()

bool QGraphicsWidget::focusNextPrevChild ( bool  next)
protectedvirtual

Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget; returns false otherwise.

If next is true, this function searches forward; if next is false, it searches backward.

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

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

See also
focusPolicy()

Reimplemented in QGraphicsProxyWidget.

Definition at line 1592 of file qgraphicswidget.cpp.

Referenced by QGraphicsProxyWidget::focusNextPrevChild(), and focusNextPrevChild().

1593 {
1595  // Let the parent's focusNextPrevChild implementation decide what to do.
1596  QGraphicsWidget *parent = 0;
1597  if (!isWindow() && (parent = parentWidget()))
1598  return parent->focusNextPrevChild(next);
1599  if (!d->scene)
1600  return false;
1601  if (d->scene->focusNextPrevChild(next))
1602  return true;
1603  if (isWindow()) {
1605  if (hasFocus())
1606  return true;
1607  }
1608  return false;
1609 }
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...
QGraphicsWidget * parentWidget() const
Returns a pointer to the item&#39;s parent widget.
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
#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.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
void setFocus(Qt::FocusReason focusReason=Qt::OtherFocusReason)
Gives keyboard input focus to this item.

◆ focusOutEvent()

void QGraphicsWidget::focusOutEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 1614 of file qgraphicswidget.cpp.

1615 {
1616  Q_UNUSED(event);
1617  if (focusPolicy() != Qt::NoFocus)
1618  update();
1619 }
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
Qt::FocusPolicy focusPolicy() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ focusPolicy()

Qt::FocusPolicy QGraphicsWidget::focusPolicy ( ) const

◆ focusWidget()

QGraphicsWidget * QGraphicsWidget::focusWidget ( ) const

If this widget, a child or descendant of this widget currently has input focus, this function will return a pointer to that widget.

If no descendant widget has input focus, 0 is returned.

See also
QGraphicsItem::focusItem(), QWidget::focusWidget()

Definition at line 1920 of file qgraphicswidget.cpp.

Referenced by QGraphicsScenePrivate::addPopup(), QGraphicsProxyWidget::event(), QGraphicsProxyWidget::focusOutEvent(), and QGraphicsProxyWidget::wheelEvent().

1921 {
1922  Q_D(const QGraphicsWidget);
1923  if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
1924  return static_cast<QGraphicsWidget *>(d->subFocusItem);
1925  return 0;
1926 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ font()

QFont QGraphicsWidget::font ( ) const

◆ geometryChanged

QGraphicsWidget::geometryChanged ( )
signal

This signal gets emitted whenever the geometry is changed in setGeometry().

Referenced by setGeometry().

◆ getContentsMargins()

void QGraphicsWidget::getContentsMargins ( qreal left,
qreal top,
qreal right,
qreal bottom 
) const
virtual

Gets the widget's contents margins.

The margins are stored in left, top, right and bottom, as pointers to qreals. Each argument can be {omitted} by passing 0.

See also
setContentsMargins()

Reimplemented from QGraphicsLayoutItem.

Definition at line 546 of file qgraphicswidget.cpp.

547 {
548  Q_D(const QGraphicsWidget);
549  if (left || top || right || bottom)
550  d->ensureMargins();
551  if (left)
552  *left = d->margins[d->Left];
553  if (top)
554  *top = d->margins[d->Top];
555  if (right)
556  *right = d->margins[d->Right];
557  if (bottom)
558  *bottom = d->margins[d->Bottom];
559 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ getWindowFrameMargins()

void QGraphicsWidget::getWindowFrameMargins ( qreal left,
qreal top,
qreal right,
qreal bottom 
) const

Gets the widget's window frame margins.

The margins are stored in left, top, right and bottom as pointers to qreals. Each argument can be {omitted} by passing 0.

See also
setWindowFrameMargins(), windowFrameRect()

Definition at line 601 of file qgraphicswidget.cpp.

602 {
603  Q_D(const QGraphicsWidget);
604  if (left || top || right || bottom)
605  d->ensureWindowFrameMargins();
606  if (left)
607  *left = d->windowFrameMargins[d->Left];
608  if (top)
609  *top = d->windowFrameMargins[d->Top];
610  if (right)
611  *right = d->windowFrameMargins[d->Right];
612  if (bottom)
613  *bottom = d->windowFrameMargins[d->Bottom];
614 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ grabKeyboardEvent()

void QGraphicsWidget::grabKeyboardEvent ( QEvent event)
protectedvirtual

This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::GrabKeyboard events.

See also
grabKeyboard(), grabMouse()

Definition at line 1755 of file qgraphicswidget.cpp.

Referenced by event().

1756 {
1757  Q_UNUSED(event);
1758 }
#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

◆ grabMouseEvent()

void QGraphicsWidget::grabMouseEvent ( QEvent event)
protectedvirtual

This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::GrabMouse events.

See also
grabMouse(), grabKeyboard()

Reimplemented in QGraphicsProxyWidget.

Definition at line 1733 of file qgraphicswidget.cpp.

Referenced by event().

1734 {
1735  Q_UNUSED(event);
1736 }
#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

◆ grabShortcut()

int QGraphicsWidget::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.

Since
4.5

If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut. For widgets that are not part of a window (i.e., top-level widgets and their children), Qt::WindowShortcut shortcuts apply to the scene.

If the same key sequence has been grabbed by several widgets, when the key sequence occurs a QEvent::Shortcut event is sent to all the widgets to which it applies in a non-deterministic order, but with the ``ambiguous'' flag set to true.

Warning
You should not normally need to use this function; instead create QAction with the shortcut key sequences you require (if you also want equivalent menu options and toolbar buttons), or create QShortcut if you just need key sequences. Both QAction and QShortcut handle all the event filtering for you, and provide signals which are triggered when the user triggers the key sequence, so are much easier to use than this low-level function.
See also
releaseShortcut() setShortcutEnabled() QWidget::grabShortcut()

Definition at line 1959 of file qgraphicswidget.cpp.

1960 {
1961  Q_ASSERT(qApp);
1962  if (sequence.isEmpty())
1963  return 0;
1964  // ### setAttribute(Qt::WA_GrabbedShortcut);
1965  return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context);
1966 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.

◆ hideEvent()

void QGraphicsWidget::hideEvent ( QHideEvent event)
protectedvirtual

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

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

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

focusNextPrevChild(true), don't lose focus when the focus widget

Reimplemented in QGraphicsProxyWidget.

Definition at line 1633 of file qgraphicswidget.cpp.

Referenced by event().

1634 {
1636  // is hidden.
1637  Q_UNUSED(event);
1638 }
#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 QGraphicsWidget::hoverLeaveEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Reimplemented in QGraphicsProxyWidget.

Definition at line 1722 of file qgraphicswidget.cpp.

1723 {
1724  Q_UNUSED(event);
1725 }
#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 QGraphicsWidget::hoverMoveEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Reimplemented in QGraphicsProxyWidget.

Definition at line 1714 of file qgraphicswidget.cpp.

1715 {
1716  Q_UNUSED(event);
1717 }
#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

◆ initStyleOption()

void QGraphicsWidget::initStyleOption ( QStyleOption option) const
protectedvirtual

Populates a style option object for this widget based on its current state, and stores the output in option.

The default implementation populates option with the following properties.

Style Option Property Value
state & QStyle::State_Enabled Corresponds to QGraphicsItem::isEnabled().
state & QStyle::State_HasFocus Corresponds to QGraphicsItem::hasFocus().
state & QStyle::State_MouseOver Corresponds to QGraphicsItem::isUnderMouse().
direction Corresponds to QGraphicsWidget::layoutDirection().
rect Corresponds to QGraphicsWidget::rect().toRect().
palette Corresponds to QGraphicsWidget::palette().
fontMetrics Corresponds to QFontMetrics(QGraphicsWidget::font()).

Subclasses of QGraphicsWidget should call the base implementation, and then test the type of option using qstyleoption_cast<>() or test QStyleOption::Type before storing widget-specific options.

For example:

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

Definition at line 709 of file qgraphicswidget.cpp.

Referenced by paintWindowFrame().

710 {
711  Q_ASSERT(option);
712 
713  option->state = QStyle::State_None;
714  if (isEnabled())
715  option->state |= QStyle::State_Enabled;
716  if (hasFocus())
717  option->state |= QStyle::State_HasFocus;
718  // if (window->testAttribute(Qt::WA_KeyboardFocusChange)) // ### Window
719  // option->state |= QStyle::State_KeyboardFocusChange;
720  if (isUnderMouse())
721  option->state |= QStyle::State_MouseOver;
722  if (QGraphicsWidget *w = window()) {
723  if (w->isActiveWindow())
724  option->state |= QStyle::State_Active;
725  }
726  if (isWindow())
727  option->state |= QStyle::State_Window;
728  /*
729  ###
730 #ifdef Q_WS_MAC
731  extern bool qt_mac_can_clickThrough(const QGraphicsWidget *w); //qwidget_mac.cpp
732  if (!(option->state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
733  option->state &= ~QStyle::State_Enabled;
734 
735  switch (QMacStyle::widgetSizePolicy(widget)) {
736  case QMacStyle::SizeSmall:
737  option->state |= QStyle::State_Small;
738  break;
739  case QMacStyle::SizeMini:
740  option->state |= QStyle::State_Mini;
741  break;
742  default:
743  ;
744  }
745 #endif
746 #ifdef QT_KEYPAD_NAVIGATION
747  if (widget->hasEditFocus())
748  state |= QStyle::State_HasEditFocus;
749 #endif
750  */
751  option->direction = layoutDirection();
752  option->rect = rect().toRect(); // ### truncation!
753  option->palette = palette();
754  if (!isEnabled()) {
756  } else if (isActiveWindow()) {
758  } else {
760  }
761  option->fontMetrics = QFontMetrics(font());
762 }
bool hasFocus() const
Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise...
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
QRectF rect() const
Returns the item&#39;s local rect as a QRectF.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
QPalette palette() const
bool isUnderMouse() const
Returns true if this item is currently under the mouse cursor in one of the views; otherwise...
QFont font() const
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
bool isActiveWindow() const
Returns true if this widget&#39;s window is in the active window, or if the widget does not have a window...
Qt::LayoutDirection layoutDirection() const
QGraphicsWidget * window() const
Returns the item&#39;s window, or 0 if this item does not have a window.
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ insertAction()

void QGraphicsWidget::insertAction ( QAction before,
QAction action 
)

Inserts the action action to this widget's list of actions, before the action before.

Since
4.5

It appends the action if before is 0 or before is not a valid action for this widget.

A QGraphicsWidget should only have one of each action.

See also
removeAction(), addAction(), QMenu, actions(), QWidget::insertActions()

Definition at line 2092 of file qgraphicswidget.cpp.

Referenced by addAction(), addActions(), and insertActions().

2093 {
2094  if (!action) {
2095  qWarning("QWidget::insertAction: Attempt to insert null action");
2096  return;
2097  }
2098 
2100  int index = d->actions.indexOf(action);
2101  if (index != -1)
2102  d->actions.removeAt(index);
2103 
2104  int pos = d->actions.indexOf(before);
2105  if (pos < 0) {
2106  before = 0;
2107  pos = d->actions.size();
2108  }
2109  d->actions.insert(pos, action);
2110 
2111  if (index == -1) {
2112  QActionPrivate *apriv = action->d_func();
2113  apriv->graphicsWidgets.append(this);
2114  }
2115 
2116  QActionEvent e(QEvent::ActionAdded, action, before);
2117  QApplication::sendEvent(this, &e);
2118 }
double d
Definition: qnumeric_p.h:62
QPointF pos() const
Returns the position of the item in parent coordinates.
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QGraphicsWidget * > graphicsWidgets
Definition: qaction_p.h:123
Q_CORE_EXPORT void qWarning(const char *,...)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
quint16 index
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ insertActions()

void QGraphicsWidget::insertActions ( QAction before,
QList< QAction *>  actions 
)

Inserts the actions actions to this widget's list of actions, before the action before.

Since
4.5

It appends the action if before is 0 or before is not a valid action for this widget.

A QGraphicsWidget can have at most one of each action.

See also
removeAction(), QMenu, insertAction(), QWidget::insertActions()

Definition at line 2134 of file qgraphicswidget.cpp.

2135 {
2136  for (int i = 0; i < actions.count(); ++i)
2137  insertAction(before, actions.at(i));
2138 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget&#39;s list of actions, before the action before.

◆ isActiveWindow()

bool QGraphicsWidget::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).

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

See also
QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), isActive()

Definition at line 1845 of file qgraphicswidget.cpp.

Referenced by initStyleOption(), and paintWindowFrame().

1846 {
1847  return isActive();
1848 }
bool isActive() const
Returns true if this item is active; otherwise returns false.

◆ itemChange()

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

QGraphicsWidget uses the base implementation of this function to catch and deliver events related to state changes in the item.

Reimplemented Function

Because of this, it is very important that subclasses call the base implementation.

change specifies the type of change, and value is the new value.

For example, QGraphicsWidget uses ItemVisibleChange to deliver Show and Hide events, ItemPositionHasChanged to deliver Move events, and ItemParentChange both to deliver ParentChange events, and for managing the focus chain.

QGraphicsWidget enables the ItemSendsGeometryChanges flag by default in order to track position changes.

See also
QGraphicsItem::itemChange()

Reimplemented from QGraphicsItem.

Definition at line 1171 of file qgraphicswidget.cpp.

Referenced by QGraphicsProxyWidget::itemChange().

1172 {
1174  switch (change) {
1175  case ItemEnabledHasChanged: {
1176  // Send EnabledChange after the enabled state has changed.
1179  break;
1180  }
1181  case ItemVisibleChange:
1182  if (value.toBool()) {
1183  // Send Show event before the item has been shown.
1184  QShowEvent event;
1185  QApplication::sendEvent(this, &event);
1186  bool resized = testAttribute(Qt::WA_Resized);
1187  if (!resized) {
1188  adjustSize();
1189  setAttribute(Qt::WA_Resized, false);
1190  }
1191  }
1192  break;
1193  case ItemVisibleHasChanged:
1194  if (!value.toBool()) {
1195  // Send Hide event after the item has been hidden.
1196  QHideEvent event;
1197  QApplication::sendEvent(this, &event);
1198  }
1199  break;
1201  d->setGeometryFromSetPos();
1202  break;
1203  case ItemParentChange: {
1204  // Deliver ParentAboutToChange.
1206  QApplication::sendEvent(this, &event);
1207  break;
1208  }
1209  case ItemParentHasChanged: {
1210  // Deliver ParentChange.
1212  QApplication::sendEvent(this, &event);
1213  break;
1214  }
1215  case ItemCursorHasChanged: {
1216  // Deliver CursorChange.
1218  QApplication::sendEvent(this, &event);
1219  break;
1220  }
1221  case ItemToolTipHasChanged: {
1222  // Deliver ToolTipChange.
1224  QApplication::sendEvent(this, &event);
1225  break;
1226  }
1227  case ItemChildAddedChange: {
1228  QGraphicsItem *child = qVariantValue<QGraphicsItem *>(value);
1229  if (child->isWidget())
1230  static_cast<QGraphicsWidget *>(child)->d_func()->resolveLayoutDirection();
1231  break;
1232  }
1233  default:
1234  break;
1235  }
1236  return QGraphicsItem::itemChange(change, value);
1237 }
double d
Definition: qnumeric_p.h:62
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
This virtual function is called by QGraphicsItem to notify custom items that some part of the item&#39;s ...
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
#define Q_D(Class)
Definition: qglobal.h:2482
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
bool event(QEvent *event)
Handles the event.
bool isWidget() const
Returns true if this item is a widget (i.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void adjustSize()
Adjusts the size of the widget to its effective preferred size hint.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ layout()

QGraphicsLayout* QGraphicsWidget::layout ( ) const

Referenced by sizeHint().

◆ layoutChanged

void QGraphicsWidget::layoutChanged ( )
signal

This signal gets emitted whenever the layout of the item changes.

Warning
This function is not part of the public interface.

Referenced by setLayout().

◆ layoutDirection()

Qt::LayoutDirection QGraphicsWidget::layoutDirection ( ) const

Referenced by adjustSize(), and initStyleOption().

◆ moveEvent()

void QGraphicsWidget::moveEvent ( QGraphicsSceneMoveEvent event)
protectedvirtual

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

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

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

See also
ItemPositionChange, ItemPositionHasChanged

Definition at line 1655 of file qgraphicswidget.cpp.

Referenced by event().

1656 {
1657  // ### Last position is always == current position
1658  Q_UNUSED(event);
1659 }
#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

◆ paint()

void QGraphicsWidget::paint ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget = 0 
)
virtual

Reimplemented Function

Implements QGraphicsItem.

Definition at line 2305 of file qgraphicswidget.cpp.

Referenced by _q_paintItem().

2306 {
2307  Q_UNUSED(painter);
2308  Q_UNUSED(option);
2309  Q_UNUSED(widget);
2310 }
#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

◆ paintWindowFrame()

void QGraphicsWidget::paintWindowFrame ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget = 0 
)
virtual

This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates.

The base implementation uses the current style to render the frame and title bar.

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

See also
QGraphicsItem::paint()

Definition at line 2323 of file qgraphicswidget.cpp.

Referenced by _q_paintItem().

2325 {
2329  const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();
2330 
2331  if (rect().contains(option->exposedRect)) {
2332  if (fillBackground && !embeddedWidgetFillsOwnBackground)
2333  painter->fillRect(option->exposedRect, palette().window());
2334  return;
2335  }
2336 
2338 
2341  bar.QStyleOption::operator=(*option);
2342  d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state
2343  d->ensureWindowData();
2344  if (d->windowData->buttonMouseOver)
2346  else
2347  bar.state &= ~QStyle::State_MouseOver;
2348  if (d->windowData->buttonSunken)
2349  bar.state |= QStyle::State_Sunken;
2350  else
2351  bar.state &= ~QStyle::State_Sunken;
2352 
2353  bar.rect = windowFrameRect;
2354 
2355  // translate painter to make the style happy
2356  const QPointF styleOrigin = this->windowFrameRect().topLeft();
2357  painter->translate(styleOrigin);
2358 
2359 #ifdef Q_WS_MAC
2360  const QSize pixmapSize = windowFrameRect.size();
2361  if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0)
2362  return;
2363  QPainter *realPainter = painter;
2364  QPixmap pm(pixmapSize);
2365  painter = new QPainter(&pm);
2366 #endif
2367 
2368  // Fill background
2369  QStyleHintReturnMask mask;
2370  bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
2371  bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);
2372  int frameWidth = style()->pixelMetric(QStyle::PM_MDIFrameWidth, &bar, widget);
2373  if (setMask) {
2374  painter->save();
2375  painter->setClipRegion(mask.region, Qt::IntersectClip);
2376  }
2377  if (fillBackground) {
2378  if (embeddedWidgetFillsOwnBackground) {
2379  // Don't fill the background twice.
2380  QPainterPath windowFrameBackground;
2381  windowFrameBackground.addRect(windowFrameRect);
2382  // Adjust with 0.5 to avoid border artifacts between
2383  // widget background and frame background.
2384  windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
2385  painter->fillPath(windowFrameBackground, palette().window());
2386  } else {
2387  painter->fillRect(windowFrameRect, palette().window());
2388  }
2389  }
2391 
2392  // Draw title
2393  int height = (int)d->titleBarHeight(bar);
2394  bar.rect.setHeight(height);
2395  if (hasBorder) // Frame is painted by PE_FrameWindow
2396  bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
2397 
2398  painter->save();
2399  painter->setFont(QApplication::font("QWorkspaceTitleBar"));
2400  style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget);
2401  painter->restore();
2402  if (setMask)
2403  painter->restore();
2404  // Draw window frame
2405  QStyleOptionFrame frameOptions;
2406  frameOptions.QStyleOption::operator=(*option);
2407  initStyleOption(&frameOptions);
2408  if (!hasBorder)
2409  painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip);
2410  if (hasFocus()) {
2411  frameOptions.state |= QStyle::State_HasFocus;
2412  } else {
2413  frameOptions.state &= ~QStyle::State_HasFocus;
2414  }
2415  bool isActive = isActiveWindow();
2416  if (isActive) {
2417  frameOptions.state |= QStyle::State_Active;
2418  } else {
2419  frameOptions.state &= ~QStyle::State_Active;
2420  }
2421 
2423  frameOptions.rect = windowFrameRect;
2424  frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget);
2425  frameOptions.midLineWidth = 1;
2426  style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget);
2427 
2428 #ifdef Q_WS_MAC
2429  realPainter->drawPixmap(QPoint(), pm);
2430  delete painter;
2431 #endif
2432 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
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...
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
virtual void initStyleOption(QStyleOption *option) const
Populates a style option object for this widget based on its current state, and stores the output in ...
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QRectF rect() const
Returns the item&#39;s local rect as a QRectF.
#define Q_D(Class)
Definition: qglobal.h:2482
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
static QFont font()
Returns the default application font.
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
int width() const
Returns the width.
Definition: qsize.h:126
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
QPalette palette() const
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
Definition: qpainter.cpp:3456
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QSizeF size() const
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
bool isActive() const
Returns true if this item is active; otherwise returns false.
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, QRectF gradientRect=QRectF())
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
QRectF windowFrameGeometry() const
Returns the widget&#39;s geometry in parent coordinates including any window frame.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
bool isActiveWindow() const
Returns true if this widget&#39;s window is in the active window, or if the widget does not have a window...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
QGraphicsWidget * window() const
Returns the item&#39;s window, or 0 if this item does not have a window.
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
QStyle * style() const
Returns a pointer to the widget&#39;s style.
QRectF windowFrameRect() const
Returns the widget&#39;s local rect including any window frame.
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
QRectF exposedRect
the exposed rectangle, in item coordinates
Definition: qstyleoption.h:873
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QWidget * widget() const
Returns a pointer to the embedded widget.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ palette()

QPalette QGraphicsWidget::palette ( ) const

◆ polishEvent()

void QGraphicsWidget::polishEvent ( )
protectedvirtual

This event is delivered to the item by the scene at some point after it has been constructed, but before it is shown or otherwise accessed through the scene.

You can use this event handler to do last-minute initializations of the widget which require the item to be fully constructed.

The base implementation does nothing.

Definition at line 1669 of file qgraphicswidget.cpp.

Referenced by event().

1670 {
1671 }

◆ propertyChange()

QVariant QGraphicsWidget::propertyChange ( const QString propertyName,
const QVariant value 
)
protectedvirtual

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.

The function returns the new value, which may be different from value if the notification supports adjusting the property value. The base implementation simply returns value for any propertyName.

QGraphicsWidget delivers notifications for the following properties:

propertyName

Property

layoutDirection

QGraphicsWidget::layoutDirection

size

QGraphicsWidget::size

font

QGraphicsWidget::font

palette

QGraphicsWidget::palette

See also
itemChange()

Definition at line 1259 of file qgraphicswidget.cpp.

1260 {
1261  Q_UNUSED(propertyName);
1262  return value;
1263 }
#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

◆ rect()

QRectF QGraphicsWidget::rect ( ) const
inline

Returns the item's local rect as a QRectF.

This function is equivalent to QRectF(QPointF(), size()).

See also
setGeometry(), resize()

Definition at line 116 of file qgraphicswidget.h.

Referenced by QGraphicsProxyWidget::hoverMoveEvent(), initStyleOption(), QGraphicsItem::mousePressEvent(), QGraphicsProxyWidget::paint(), paintWindowFrame(), setGeometry(), shape(), and windowFrameRect().

116 { return QRectF(QPointF(), size()); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QSizeF size() const

◆ releaseShortcut()

void QGraphicsWidget::releaseShortcut ( int  id)

Removes the shortcut with the given id from Qt's shortcut system.

Since
4.5

The widget will no longer receive QEvent::Shortcut events for the shortcut's key sequence (unless it has other shortcuts with the same key sequence).

Warning
You should not normally need to use this function since Qt's shortcut system removes shortcuts automatically when their parent widget is destroyed. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function. Note also that this is an expensive operation.
See also
grabShortcut() setShortcutEnabled() , QWidget::releaseShortcut()

Definition at line 1988 of file qgraphicswidget.cpp.

1989 {
1990  Q_ASSERT(qApp);
1991  if (id)
1992  qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
1993 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp

◆ removeAction()

void QGraphicsWidget::removeAction ( QAction action)

Removes the action action from this widget's list of actions.

Since
4.5
See also
insertAction(), actions(), insertAction(), QWidget::removeAction()

Definition at line 2150 of file qgraphicswidget.cpp.

Referenced by QAction::~QAction().

2151 {
2152  if (!action)
2153  return;
2154 
2156 
2157  QActionPrivate *apriv = action->d_func();
2158  apriv->graphicsWidgets.removeAll(this);
2159 
2160  if (d->actions.removeAll(action)) {
2162  QApplication::sendEvent(this, &e);
2163  }
2164 }
double d
Definition: qnumeric_p.h:62
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
#define Q_D(Class)
Definition: qglobal.h:2482
QList< QGraphicsWidget * > graphicsWidgets
Definition: qaction_p.h:123
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ resize() [1/2]

void QGraphicsWidget::resize ( const QSizeF size)

Definition at line 314 of file qgraphicswidget.cpp.

Referenced by QDeclarativeLoaderPrivate::_q_updateSize(), adjustSize(), and updateGeometry().

315 {
316  setGeometry(QRectF(pos(), size));
317 }
QPointF pos() const
Returns the position of the item in parent coordinates.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...

◆ resize() [2/2]

void QGraphicsWidget::resize ( qreal  w,
qreal  h 
)
inline

This convenience function is equivalent to calling resize(QSizeF(w, h)).

See also
setGeometry(), setTransform()

Definition at line 111 of file qgraphicswidget.h.

Referenced by resize().

111 { resize(QSizeF(w, h)); }
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void resize(const QSizeF &size)

◆ resizeEvent()

void QGraphicsWidget::resizeEvent ( QGraphicsSceneResizeEvent event)
protectedvirtual

This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i.e., its local size has changed).

event contains both the old and the new size.

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

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

See also
geometry(), setGeometry()

Reimplemented in QGraphicsProxyWidget.

Definition at line 1689 of file qgraphicswidget.cpp.

Referenced by event(), and QGraphicsProxyWidget::resizeEvent().

1690 {
1691  Q_UNUSED(event);
1692 }
#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

◆ sceneEvent()

bool QGraphicsWidget::sceneEvent ( QEvent event)
protectedvirtual

QGraphicsWidget's implementation of sceneEvent() simply passes event to QGraphicsWidget::event().

You can handle all events for your widget in event() or in any of the convenience functions; you should not have to reimplement this function in a subclass of QGraphicsWidget.

See also
QGraphicsItem::sceneEvent()

Reimplemented from QGraphicsItem.

Definition at line 1273 of file qgraphicswidget.cpp.

1274 {
1275  return QGraphicsItem::sceneEvent(event);
1276 }
virtual bool sceneEvent(QEvent *event)
This virtual function receives events to this item.

◆ setAttribute()

void QGraphicsWidget::setAttribute ( Qt::WidgetAttribute  attribute,
bool  on = true 
)

If on is true, this function enables attribute; otherwise attribute is disabled.

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

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

Definition at line 2273 of file qgraphicswidget.cpp.

Referenced by itemChange(), setFont(), setGeometry(), setLayoutDirection(), setPalette(), setStyle(), unsetLayoutDirection(), and updateGeometry().

2274 {
2276  // ### most flags require some immediate action
2277  // ### we might want to qWarn use of unsupported attributes
2278  // ### we might want to not use Qt::WidgetAttribute, but roll our own instead
2279  d->setAttribute(attribute, on);
2280 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setAutoFillBackground()

void QGraphicsWidget::setAutoFillBackground ( bool  enabled)

Definition at line 1094 of file qgraphicswidget.cpp.

1095 {
1097  if (d->autoFillBackground != enabled) {
1098  d->autoFillBackground = enabled;
1099  update();
1100  }
1101 }
double d
Definition: qnumeric_p.h:62
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
#define Q_D(Class)
Definition: qglobal.h:2482
bool enabled
whether the item is enabled or not
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setContentsMargins()

void QGraphicsWidget::setContentsMargins ( qreal  left,
qreal  top,
qreal  right,
qreal  bottom 
)

Sets the widget's contents margins to left, top, right and bottom.

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

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

See also
getContentsMargins(), setGeometry()

Definition at line 512 of file qgraphicswidget.cpp.

513 {
515 
516  if (!d->margins && left == 0 && top == 0 && right == 0 && bottom == 0)
517  return;
518  d->ensureMargins();
519  if (left == d->margins[d->Left]
520  && top == d->margins[d->Top]
521  && right == d->margins[d->Right]
522  && bottom == d->margins[d->Bottom])
523  return;
524 
525  d->margins[d->Left] = left;
526  d->margins[d->Top] = top;
527  d->margins[d->Right] = right;
528  d->margins[d->Bottom] = bottom;
529 
530  if (QGraphicsLayout *l = d->layout)
531  l->invalidate();
532  else
533  updateGeometry();
534 
536  QApplication::sendEvent(this, &e);
537 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
QFactoryLoader * l
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void updateGeometry()
If this widget is currently managed by a layout, this function notifies the layout that the widget&#39;s ...
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setFocusPolicy()

void QGraphicsWidget::setFocusPolicy ( Qt::FocusPolicy  policy)

Definition at line 1902 of file qgraphicswidget.cpp.

1903 {
1905  if (d->focusPolicy == policy)
1906  return;
1907  d->focusPolicy = policy;
1908  if (hasFocus() && policy == Qt::NoFocus)
1909  clearFocus();
1910  setFlag(ItemIsFocusable, policy != Qt::NoFocus);
1911 }
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...
void clearFocus()
Takes keyboard input focus from the item.
#define Q_D(Class)
Definition: qglobal.h:2482
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setFont()

void QGraphicsWidget::setFont ( const QFont font)

Definition at line 1017 of file qgraphicswidget.cpp.

1018 {
1020  setAttribute(Qt::WA_SetFont, font.resolve() != 0);
1021 
1022  QFont naturalFont = d->naturalWidgetFont();
1023  QFont resolvedFont = font.resolve(naturalFont);
1024  d->setFont_helper(resolvedFont);
1025 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setGeometry() [1/2]

void QGraphicsWidget::setGeometry ( const QRectF rect)
virtual

This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e.

g., the top-left corner of rect is equivalent to the item's position in parent coordinates).

You must reimplement this function in a subclass of QGraphicsLayoutItem to receive geometry updates. The layout will call this function when it does a rearrangement.

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

See also
geometry()

Reimplemented from QGraphicsLayoutItem.

Definition at line 365 of file qgraphicswidget.cpp.

Referenced by resize(), and QGraphicsProxyWidget::setGeometry().

366 {
367  QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
369  QRectF newGeom = rect;
370  QPointF oldPos = d->geom.topLeft();
371  if (!wd->inSetPos) {
375 
376  if (newGeom == d->geom) {
377  goto relayoutChildrenAndReturn;
378  }
379 
380  // setPos triggers ItemPositionChange, which can adjust position
381  wd->inSetGeometry = 1;
382  setPos(newGeom.topLeft());
383  wd->inSetGeometry = 0;
384  newGeom.moveTopLeft(pos());
385 
386  if (newGeom == d->geom) {
387  goto relayoutChildrenAndReturn;
388  }
389 
390  // Update and prepare to change the geometry (remove from index) if the size has changed.
391  if (wd->scene) {
392  if (rect.topLeft() == d->geom.topLeft()) {
394  }
395  }
396  }
397 
398  // Update the layout item geometry
399  {
400  bool moved = oldPos != pos();
401  if (moved) {
402  // Send move event.
404  event.setOldPos(oldPos);
405  event.setNewPos(pos());
406  QApplication::sendEvent(this, &event);
407  if (wd->inSetPos) {
408  //set the new pos
409  d->geom.moveTopLeft(pos());
411  goto relayoutChildrenAndReturn;
412  }
413  }
414  QSizeF oldSize = size();
416  // Send resize event
417  bool resized = newGeom.size() != oldSize;
418  if (resized) {
420  re.setOldSize(oldSize);
421  re.setNewSize(newGeom.size());
422  if (oldSize.width() != newGeom.size().width())
423  emit widthChanged();
424  if (oldSize.height() != newGeom.size().height())
426  QApplication::sendEvent(this, &re);
427  }
428  }
429 
431 relayoutChildrenAndReturn:
433  if (QGraphicsLayout *lay = wd->layout) {
434  if (!lay->isActivated()) {
435  QEvent layoutRequest(QEvent::LayoutRequest);
436  QApplication::sendEvent(this, &layoutRequest);
437  }
438  }
439  }
440 }
double d
Definition: qnumeric_p.h:62
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
virtual void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
void setNewSize(const QSizeF &size)
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
T * data() const
Returns the value of the pointer referenced by this object.
void heightChanged()
qreal width() const
Returns the width.
Definition: qsize.h:284
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal height() const
Returns the height.
Definition: qsize.h:287
QGraphicsScene * scene
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
QPointF pos() const
Returns the position of the item in parent coordinates.
void setOldSize(const QSizeF &size)
QGraphicsLayout * layout
The QGraphicsSceneMoveEvent class provides events for widget moving in the graphics view framework...
QRectF rect() const
Returns the item&#39;s local rect as a QRectF.
void setPos(const QPointF &pos)
Sets the position of the item to pos, which is in parent coordinates.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void geometryChanged()
This signal gets emitted whenever the geometry is changed in setGeometry().
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
#define emit
Definition: qobjectdefs.h:76
QSizeF size() const
void moveTopLeft(const QPointF &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:697
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool instantInvalidatePropagation()
void setSize(const QSizeF &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:790
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
bool event(QEvent *event)
Handles the event.
void prepareGeometryChange()
Prepares the item for a geometry change.
QSizeF boundedTo(const QSizeF &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:350
QSizeF expandedTo(const QSizeF &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:345
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setGeometry() [2/2]

void QGraphicsWidget::setGeometry ( qreal  x,
qreal  y,
qreal  w,
qreal  h 
)
inline

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

See also
geometry(), resize()

Definition at line 249 of file qgraphicswidget.h.

250 { setGeometry(QRectF(ax, ay, aw, ah)); }
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...

◆ setLayout()

void QGraphicsWidget::setLayout ( QGraphicsLayout layout)

Sets the layout for this widget to layout.

Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.

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

QGraphicsWidget takes ownership of layout.

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

Definition at line 859 of file qgraphicswidget.cpp.

860 {
862  if (d->layout == l)
863  return;
864  d->setLayout_helper(l);
865  if (!l)
866  return;
867 
868  // Prevent assigning a layout that is already assigned to another widget.
869  QGraphicsLayoutItem *oldParent = l->parentLayoutItem();
870  if (oldParent && oldParent != this) {
871  qWarning("QGraphicsWidget::setLayout: Attempting to set a layout on %s"
872  " \"%s\", when the layout already has a parent",
874  return;
875  }
876 
877  // Install and activate the layout.
878  l->setParentLayoutItem(this);
879  l->d_func()->reparentChildItems(this);
880  l->invalidate();
882 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
const char * className
Definition: qwizard.cpp:137
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
QString objectName() const
QFactoryLoader * l
#define qPrintable(string)
Definition: qglobal.h:1750
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
void layoutChanged()
This signal gets emitted whenever the layout of the item changes.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setLayoutDirection()

void QGraphicsWidget::setLayoutDirection ( Qt::LayoutDirection  direction)

Definition at line 933 of file qgraphicswidget.cpp.

934 {
937  d->setLayoutDirection_helper(direction);
938 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
Qt::LayoutDirection direction
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setPalette()

void QGraphicsWidget::setPalette ( const QPalette palette)

Definition at line 1060 of file qgraphicswidget.cpp.

1061 {
1063  setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);
1064 
1065  QPalette naturalPalette = d->naturalWidgetPalette();
1066  QPalette resolvedPalette = palette.resolve(naturalPalette);
1067  d->setPalette_helper(resolvedPalette);
1068 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ setShortcutAutoRepeat()

void QGraphicsWidget::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.

Since
4.5
See also
grabShortcut() releaseShortcut() QWidget::setShortcutAutoRepeat()

Definition at line 2030 of file qgraphicswidget.cpp.

2031 {
2032  Q_ASSERT(qApp);
2033  if (id)
2034  qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
2035 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp
bool enabled
whether the item is enabled or not

◆ setShortcutEnabled()

void QGraphicsWidget::setShortcutEnabled ( int  id,
bool  enabled = true 
)

If enabled is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled.

Since
4.5
Warning
You should not normally need to use this function since Qt's shortcut system enables/disables shortcuts automatically as widgets become hidden/visible and gain or lose focus. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function.
See also
grabShortcut() releaseShortcut(), QWidget::setShortcutEnabled()

Definition at line 2012 of file qgraphicswidget.cpp.

2013 {
2014  Q_ASSERT(qApp);
2015  if (id)
2016  qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
2017 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp
bool enabled
whether the item is enabled or not

◆ setStyle()

void QGraphicsWidget::setStyle ( QStyle style)

Sets the widget's style to style.

QGraphicsWidget does not take ownership of style.

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

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

See also
style()

Definition at line 975 of file qgraphicswidget.cpp.

Referenced by QGraphicsProxyWidget::eventFilter().

976 {
977  setAttribute(Qt::WA_SetStyle, style != 0);
978  widgetStyles()->setStyleForWidget(this, style);
979 
980  // Deliver StyleChange to the widget itself (doesn't propagate).
983 }
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
bool event(QEvent *event)
Handles the event.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setTabOrder()

void QGraphicsWidget::setTabOrder ( QGraphicsWidget first,
QGraphicsWidget second 
)
static

Moves the second widget around the ring of focus widgets so that keyboard focus moves from the first widget to the second widget when the Tab key is pressed.

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

setTabOrder(a, b); // a to b
setTabOrder(b, c); // a to b to c
setTabOrder(c, d); // a to b to c to d

not like this:

// WRONG
setTabOrder(c, d); // c to d
setTabOrder(a, b); // a to b AND c to d
setTabOrder(b, c); // a to b to c, but not c to d

If first is 0, this indicates that second should be the first widget to receive input focus should the scene gain Tab focus (i.e., the user hits Tab so that focus passes into the scene). If second is 0, this indicates that first should be the first widget to gain focus if the scene gained BackTab focus.

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

See also
focusPolicy, {Keyboard Focus}

Definition at line 2208 of file qgraphicswidget.cpp.

2209 {
2210  if (!first && !second) {
2211  qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined");
2212  return;
2213  }
2214  if ((first && second) && first->scene() != second->scene()) {
2215  qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different",
2216  first->scene(), second->scene());
2217  return;
2218  }
2219  QGraphicsScene *scene = first ? first->scene() : second->scene();
2220  if (!scene && (!first || !second)) {
2221  qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"
2222  " scene requires the item to be in a scene.");
2223  return;
2224  }
2225 
2226  // If either first or second are 0, the scene's tabFocusFirst is updated
2227  // to point to the first item in the scene's focus chain. Then first or
2228  // second are set to point to tabFocusFirst.
2229  QGraphicsScenePrivate *sceneD = scene->d_func();
2230  if (!first) {
2231  sceneD->tabFocusFirst = second;
2232  return;
2233  }
2234  if (!second) {
2235  sceneD->tabFocusFirst = first->d_func()->focusNext;
2236  return;
2237  }
2238 
2239  // Both first and second are != 0.
2240  QGraphicsWidget *firstFocusNext = first->d_func()->focusNext;
2241  if (firstFocusNext == second) {
2242  // Nothing to do.
2243  return;
2244  }
2245 
2246  // Update the focus chain.
2247  QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev;
2248  QGraphicsWidget *secondFocusNext = second->d_func()->focusNext;
2249  firstFocusNext->d_func()->focusPrev = second;
2250  first->d_func()->focusNext = second;
2251  second->d_func()->focusNext = firstFocusNext;
2252  second->d_func()->focusPrev = first;
2253  secondFocusPrev->d_func()->focusNext = secondFocusNext;
2254  secondFocusNext->d_func()->focusPrev = secondFocusPrev;
2255 
2256  Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first);
2257  Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first);
2258 
2259  Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
2260  Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
2261 
2262 }
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qWarning(const char *,...)
QGraphicsWidget * tabFocusFirst
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setWindowFlags()

void QGraphicsWidget::setWindowFlags ( Qt::WindowFlags  wFlags)

Definition at line 1806 of file qgraphicswidget.cpp.

1807 {
1809  if (d->windowFlags == wFlags)
1810  return;
1811  bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
1812 
1813  d->adjustWindowFlags(&wFlags);
1814  d->windowFlags = wFlags;
1815  if (!d->setWindowFrameMargins)
1817 
1818  setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
1819 
1820  bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
1821  if (d->scene && isVisible() && wasPopup != isPopup) {
1822  // Popup state changed; update implicit mouse grab.
1823  if (!isPopup)
1824  d->scene->d_func()->removePopup(this);
1825  else
1826  d->scene->d_func()->addPopup(this);
1827  }
1828 
1829  if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
1830  d->scene->d_func()->allItemsIgnoreHoverEvents = false;
1831  d->scene->d_func()->enableMouseTrackingOnViews();
1832  }
1833 }
double d
Definition: qnumeric_p.h:62
bool isPopup
Use windowType() == Qt::Popup instead.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
#define Q_D(Class)
Definition: qglobal.h:2482
void unsetWindowFrameMargins()
Resets the window frame margins to the default value, provided by the style.
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setWindowFrameMargins()

void QGraphicsWidget::setWindowFrameMargins ( qreal  left,
qreal  top,
qreal  right,
qreal  bottom 
)

Sets the widget's window frame margins to left, top, right and bottom.

The default frame margins are provided by the style, and they depend on the current window flags.

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

See also
unsetWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()

Definition at line 571 of file qgraphicswidget.cpp.

Referenced by unsetWindowFrameMargins().

572 {
574 
575  if (!d->windowFrameMargins && left == 0 && top == 0 && right == 0 && bottom == 0)
576  return;
577  d->ensureWindowFrameMargins();
578  bool unchanged =
579  d->windowFrameMargins[d->Left] == left
580  && d->windowFrameMargins[d->Top] == top
581  && d->windowFrameMargins[d->Right] == right
582  && d->windowFrameMargins[d->Bottom] == bottom;
583  if (d->setWindowFrameMargins && unchanged)
584  return;
585  if (!unchanged)
587  d->windowFrameMargins[d->Left] = left;
588  d->windowFrameMargins[d->Top] = top;
589  d->windowFrameMargins[d->Right] = right;
590  d->windowFrameMargins[d->Bottom] = bottom;
591  d->setWindowFrameMargins = true;
592 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void prepareGeometryChange()
Prepares the item for a geometry change.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setWindowTitle()

void QGraphicsWidget::setWindowTitle ( const QString title)

Definition at line 1862 of file qgraphicswidget.cpp.

1863 {
1865  d->ensureWindowData();
1866  d->windowData->windowTitle = title;
1867 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ shape()

QPainterPath QGraphicsWidget::shape ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 2445 of file qgraphicswidget.cpp.

2446 {
2447  QPainterPath path;
2448  path.addRect(rect());
2449  return path;
2450 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QRectF rect() const
Returns the item&#39;s local rect as a QRectF.
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.

◆ showEvent()

void QGraphicsWidget::showEvent ( QShowEvent event)
protectedvirtual

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

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

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

Reimplemented in QGraphicsProxyWidget.

Definition at line 1706 of file qgraphicswidget.cpp.

Referenced by event().

1707 {
1708  Q_UNUSED(event);
1709 }
#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

◆ size()

QSizeF QGraphicsWidget::size ( ) const

◆ sizeHint()

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

Reimplemented Function

Implements QGraphicsLayoutItem.

Definition at line 767 of file qgraphicswidget.cpp.

Referenced by QGraphicsProxyWidget::sizeHint().

768 {
769  Q_D(const QGraphicsWidget);
770  QSizeF sh;
771  if (d->layout) {
772  QSizeF marginSize(0,0);
773  if (d->margins) {
774  marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right],
775  d->margins[d->Top] + d->margins[d->Bottom]);
776  }
777  sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
778  sh += marginSize;
779  } else {
780  switch (which) {
781  case Qt::MinimumSize:
782  sh = QSizeF(0, 0);
783  break;
784  case Qt::PreferredSize:
785  sh = QSizeF(50, 50); //rather arbitrary
786  break;
787  case Qt::MaximumSize:
789  break;
790  default:
791  qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
792  break;
793  }
794  }
795  return sh;
796 }
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
Q_CORE_EXPORT void qWarning(const char *,...)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ style()

QStyle * QGraphicsWidget::style ( ) const

Returns a pointer to the widget's style.

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

See also
setStyle()

Definition at line 954 of file qgraphicswidget.cpp.

Referenced by QGraphicsProxyWidget::event(), paintWindowFrame(), QGraphicsWidgetStyles::setStyleForWidget(), QGraphicsAnchorLayoutPrivate::styleInfo(), and unsetWindowFrameMargins().

955 {
956  if (QStyle *style = widgetStyles()->styleForWidget(this))
957  return style;
958  // ### This is not thread-safe. QApplication::style() is not thread-safe.
959  return scene() ? scene()->style() : QApplication::style();
960 }
static QStyle * style()
Returns the application&#39;s style object.
QStyle * style() const
Returns the scene&#39;s style, or the same as QApplication::style() if the scene has not been explicitly ...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
QStyle * style() const
Returns a pointer to the widget&#39;s style.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.

◆ testAttribute()

bool QGraphicsWidget::testAttribute ( Qt::WidgetAttribute  attribute) const

Returns true if attribute is enabled for this widget; otherwise, returns false.

See also
setAttribute()

Definition at line 2288 of file qgraphicswidget.cpp.

Referenced by adjustSize(), close(), itemChange(), paintWindowFrame(), QGraphicsWidgetPrivate::setLayoutDirection_helper(), QGraphicsScene::setStyle(), QGraphicsWidgetPrivate::updateFont(), updateGeometry(), and QGraphicsWidgetPrivate::updatePalette().

2289 {
2290  Q_D(const QGraphicsWidget);
2291  return d->testAttribute(attribute);
2292 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ type()

int QGraphicsWidget::type ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 2297 of file qgraphicswidget.cpp.

2298 {
2299  return Type;
2300 }

◆ ungrabKeyboardEvent()

void QGraphicsWidget::ungrabKeyboardEvent ( QEvent event)
protectedvirtual

This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::UngrabKeyboard events.

See also
ungrabKeyboard(), ungrabMouse()

Definition at line 1766 of file qgraphicswidget.cpp.

Referenced by event().

1767 {
1768  Q_UNUSED(event);
1769 }
#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

◆ ungrabMouseEvent()

void QGraphicsWidget::ungrabMouseEvent ( QEvent event)
protectedvirtual

This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent::UngrabMouse events.

See also
ungrabMouse(), ungrabKeyboard()

Reimplemented in QGraphicsProxyWidget.

Definition at line 1744 of file qgraphicswidget.cpp.

Referenced by event().

1745 {
1746  Q_UNUSED(event);
1747 }
#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

◆ unsetLayoutDirection()

void QGraphicsWidget::unsetLayoutDirection ( )

Definition at line 939 of file qgraphicswidget.cpp.

940 {
943  d->resolveLayoutDirection();
944 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ unsetWindowFrameMargins()

void QGraphicsWidget::unsetWindowFrameMargins ( )

Resets the window frame margins to the default value, provided by the style.

See also
setWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()

Definition at line 621 of file qgraphicswidget.cpp.

Referenced by changeEvent(), and setWindowFlags().

622 {
624  if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
625  (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
627  d->initStyleOptionTitleBar(&bar);
628  QStyle *style = this->style();
630  qreal titleBarHeight = d->titleBarHeight(bar);
631  setWindowFrameMargins(margin, titleBarHeight, margin, margin);
632  } else {
633  setWindowFrameMargins(0, 0, 0, 0);
634  }
635  d->setWindowFrameMargins = false;
636 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
#define Q_D(Class)
Definition: qglobal.h:2482
void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom)
Sets the widget&#39;s window frame margins to left, top, right and bottom.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
QStyle * style() const
Returns a pointer to the widget&#39;s style.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ updateGeometry()

void QGraphicsWidget::updateGeometry ( )
protectedvirtual

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.

Call this function if the widget's sizeHint() has changed.

See also
QGraphicsLayout::invalidate()

If this is the topmost widget, post a LayoutRequest event to the widget. When the event is received, it will start flowing all the way down to the leaf widgets in one go. This will make a relayout flicker-free.

Reimplemented from QGraphicsLayoutItem.

Definition at line 1112 of file qgraphicswidget.cpp.

Referenced by changeEvent(), QGraphicsProxyWidget::eventFilter(), and setContentsMargins().

1113 {
1116 
1117  if (parentItem && parentItem->isLayout()) {
1119  static_cast<QGraphicsLayout *>(parentItem)->invalidate();
1120  } else {
1121  parentItem->updateGeometry();
1122  }
1123  } else {
1124  if (parentItem) {
1125  // This is for custom layouting
1126  QGraphicsWidget *parentWid = parentWidget(); //###
1127  if (parentWid->isVisible())
1129  } else {
1137  ++d->refCountInvokeRelayout;
1138  QMetaObject::invokeMethod(this, "_q_relayout", Qt::QueuedConnection);
1139  }
1140  }
1142  bool wasResized = testAttribute(Qt::WA_Resized);
1143  resize(size()); // this will restrict the size
1144  setAttribute(Qt::WA_Resized, wasResized);
1145  }
1146  }
1147 }
double d
Definition: qnumeric_p.h:62
QGraphicsWidget * parentWidget() const
Returns a pointer to the item&#39;s parent widget.
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
#define Q_D(Class)
Definition: qglobal.h:2482
QSizeF size() const
virtual void updateGeometry()
This virtual function discards any cached size hint information.
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
static bool instantInvalidatePropagation()
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
bool isLayout() const
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges o...
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
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.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void resize(const QSizeF &size)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFlags()

Qt::WindowFlags QGraphicsWidget::windowFlags ( ) const

Referenced by windowType().

◆ windowFrameEvent()

bool QGraphicsWidget::windowFrameEvent ( QEvent event)
protectedvirtual

This event handler, for event, receives events for the window frame if this widget is a window.

Its base implementation provides support for default window frame interaction such as moving, resizing, etc.

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

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

See also
event()

Definition at line 1291 of file qgraphicswidget.cpp.

Referenced by event().

1292 {
1294  switch (event->type()) {
1296  d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1297  break;
1299  d->ensureWindowData();
1300  if (d->windowData->grabbedSection != Qt::NoSection) {
1301  d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1302  event->accept();
1303  }
1304  break;
1306  d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1307  break;
1309  d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
1310  break;
1312  d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
1313  break;
1314  default:
1315  break;
1316  }
1317  return event->isAccepted();
1318 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameGeometry()

QRectF QGraphicsWidget::windowFrameGeometry ( ) const

Returns the widget's geometry in parent coordinates including any window frame.

See also
windowFrameRect(), getWindowFrameMargins(), setWindowFrameMargins()

Definition at line 644 of file qgraphicswidget.cpp.

Referenced by paintWindowFrame().

645 {
646  Q_D(const QGraphicsWidget);
647  return d->windowFrameMargins
648  ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
649  d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
650  : geometry();
651 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF geometry() const
Returns the item&#39;s geometry (e.
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:781
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameRect()

QRectF QGraphicsWidget::windowFrameRect ( ) const

Returns the widget's local rect including any window frame.

See also
windowFrameGeometry(), getWindowFrameMargins(), setWindowFrameMargins()

Definition at line 658 of file qgraphicswidget.cpp.

Referenced by boundingRect(), QGraphicsSceneIndexPrivate::itemCollidesWithPath(), paintWindowFrame(), and windowFrameSectionAt().

659 {
660  Q_D(const QGraphicsWidget);
661  return d->windowFrameMargins
662  ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
663  d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
664  : rect();
665 }
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
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:781
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameSectionAt()

Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt ( const QPointF pos) const
protectedvirtual

Returns the window frame section at position pos, or Qt::NoSection if there is no window frame section at this position.

Since
4.4

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

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

See also
windowFrameEvent(), paintWindowFrame(), windowFrameGeometry()

Definition at line 1341 of file qgraphicswidget.cpp.

1342 {
1343  Q_D(const QGraphicsWidget);
1344 
1345  const QRectF r = windowFrameRect();
1346  if (!r.contains(pos))
1347  return Qt::NoSection;
1348 
1349  const qreal left = r.left();
1350  const qreal top = r.top();
1351  const qreal right = r.right();
1352  const qreal bottom = r.bottom();
1353  const qreal x = pos.x();
1354  const qreal y = pos.y();
1355 
1356  const qreal cornerMargin = 20;
1357  //### Not sure of this one, it should be the same value for all edges.
1358  const qreal windowFrameWidth = d->windowFrameMargins
1359  ? d->windowFrameMargins[d->Left] : 0;
1360 
1362  if (x <= left + cornerMargin) {
1363  if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) {
1364  s = Qt::TopLeftSection;
1365  } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - windowFrameWidth)) {
1367  } else if (x <= left + windowFrameWidth) {
1368  s = Qt::LeftSection;
1369  }
1370  } else if (x >= right - cornerMargin) {
1371  if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) {
1372  s = Qt::TopRightSection;
1373  } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - windowFrameWidth)) {
1375  } else if (x >= right - windowFrameWidth) {
1376  s = Qt::RightSection;
1377  }
1378  } else if (y <= top + windowFrameWidth) {
1379  s = Qt::TopSection;
1380  } else if (y >= bottom - windowFrameWidth) {
1381  s = Qt::BottomSection;
1382  }
1383  if (s == Qt::NoSection) {
1384  QRectF r1 = r;
1385  r1.setHeight(d->windowFrameMargins
1386  ? d->windowFrameMargins[d->Top] : 0);
1387  if (r1.contains(pos))
1388  s = Qt::TitleBarArea;
1389  }
1390  return s;
1391 }
double d
Definition: qnumeric_p.h:62
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
void setHeight(qreal h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:787
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal y() const
This convenience function is equivalent to calling pos().
qreal x() const
This convenience function is equivalent to calling pos().
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
QRectF windowFrameRect() const
Returns the widget&#39;s local rect including any window frame.
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
WindowFrameSection
Definition: qnamespace.h:1716
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowTitle()

QString QGraphicsWidget::windowTitle ( ) const

Referenced by setWindowTitle().

◆ windowType()

Qt::WindowType QGraphicsWidget::windowType ( ) const

Returns the widgets window type.

See also
windowFlags(), isWindow(), isPanel()

Definition at line 1776 of file qgraphicswidget.cpp.

Referenced by _q_paintItem(), QShortcutMap::correctGraphicsWidgetContext(), and QGraphicsItemPrivate::setVisibleHelper().

1777 {
1779 }
WindowType
Definition: qnamespace.h:270
Qt::WindowFlags windowFlags() const

Friends and Related Functions

◆ QApplication

friend class QApplication
friend

Definition at line 246 of file qgraphicswidget.h.

◆ QGraphicsItem

friend class QGraphicsItem
friend

Definition at line 242 of file qgraphicswidget.h.

◆ QGraphicsItemPrivate

friend class QGraphicsItemPrivate
friend

Definition at line 243 of file qgraphicswidget.h.

◆ QGraphicsLayout

friend class QGraphicsLayout
friend

Definition at line 244 of file qgraphicswidget.h.

◆ QGraphicsScene

friend class QGraphicsScene
friend

Definition at line 239 of file qgraphicswidget.h.

◆ QGraphicsScenePrivate

Definition at line 240 of file qgraphicswidget.h.

◆ QGraphicsView

friend class QGraphicsView
friend

Definition at line 241 of file qgraphicswidget.h.

◆ QWidget

friend class QWidget
friend

Definition at line 245 of file qgraphicswidget.h.

Properties

◆ autoFillBackground

bool QGraphicsWidget::autoFillBackground
private

whether the widget background is filled automatically

Since
4.7

If enabled, this property will cause Qt to fill the background of the widget before invoking the paint() method. The color used is defined by the QPalette::Window color role from the widget's palette.

In addition, Windows are always filled with QPalette::Window, unless the WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.

By default, this property is false.

See also
Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,

Definition at line 85 of file qgraphicswidget.h.

Referenced by _q_paintItem().

◆ focusPolicy

Qt::FocusPolicy QGraphicsWidget::focusPolicy
private

the way the widget accepts keyboard focus

The focus policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it does not accept focus at all.

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

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

See also
focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled

Definition at line 81 of file qgraphicswidget.h.

Referenced by QGraphicsScene::focusNextPrevChild().

◆ font

QFont QGraphicsWidget::font
private

the widgets' font

This property provides the widget's font.

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

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

By default, this property contains the application's default font.

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

Definition at line 74 of file qgraphicswidget.h.

◆ geometry

QGraphicsWidget::geometry
private

the geometry of the widget

Sets the item's geometry to rect. The item's position and size are modified as a result of calling this function. The item is first moved, then resized.

A side effect of calling this function is that the widget will receive a move event and a resize event. Also, if the widget has a layout assigned, the layout will activate.

See also
geometry(), resize()

Definition at line 84 of file qgraphicswidget.h.

◆ layout

QGraphicsLayout * QGraphicsWidget::layout
private

The layout of the widget.

Returns this widget's layout, or 0 if no layout is currently managing this widget.

Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.

QGraphicsWidget takes ownership of layout.

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

If no layout is currently managing this widget, layout() will return 0.

See also
setLayout()

Definition at line 86 of file qgraphicswidget.h.

Referenced by QGraphicsLayoutItemPrivate::hasHeightForWidth(), and QGraphicsLayoutItemPrivate::hasWidthForHeight().

◆ layoutDirection

Qt::LayoutDirection QGraphicsWidget::layoutDirection
private

the layout direction for this widget.

This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.

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

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

See also
QWidget::layoutDirection, QApplication::layoutDirection

Definition at line 75 of file qgraphicswidget.h.

Referenced by _q_paintItem().

◆ maximumSize

QGraphicsWidget::maximumSize
private

the maximum size of the widget

See also
setMaximumSize(), maximumSize(), minimumSize, preferredSize

Definition at line 79 of file qgraphicswidget.h.

◆ minimumSize

QGraphicsWidget::minimumSize
private

the minimum size of the widget

See also
setMinimumSize(), minimumSize(), preferredSize, maximumSize

Definition at line 77 of file qgraphicswidget.h.

◆ palette

QPalette QGraphicsWidget::palette
private

the widget's palette

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

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

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

By default, this property contains the application's default palette.

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

Definition at line 73 of file qgraphicswidget.h.

Referenced by _q_paintItem().

◆ preferredSize

QGraphicsWidget::preferredSize
private

the preferred size of the widget

See also
setPreferredSize(), preferredSize(), minimumSize, maximumSize

Definition at line 78 of file qgraphicswidget.h.

◆ size

QSizeF QGraphicsWidget::size
private

the size of the widget

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

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

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

By default, this property contains a size with zero width and height.

See also
setGeometry(), QGraphicsSceneResizeEvent, QGraphicsLayout

Definition at line 76 of file qgraphicswidget.h.

Referenced by _q_boundGeometryToSizeConstraints(), QDeclarativeLoaderPrivate::_q_updateSize(), and closestAcceptableSize().

◆ sizePolicy

QGraphicsWidget::sizePolicy
private

the size policy for the widget

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

Definition at line 80 of file qgraphicswidget.h.

◆ windowFlags

Qt::WindowFlags QGraphicsWidget::windowFlags
private

the widget's window flags

Window flags are a combination of a window type (e.g., Qt::Dialog) and several flags giving hints on the behavior of the window. The behavior is platform-dependent.

By default, this property contains no window flags.

Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag will be set automatically. If you clear the Qt::Window flag, the ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be set independently of Qt::Window.

See also
isWindow(), isPanel()

Definition at line 82 of file qgraphicswidget.h.

Referenced by _q_paintItem(), and QGraphicsItem::mousePressEvent().

◆ windowTitle

QString QGraphicsWidget::windowTitle
private

This property holds the window title (caption).

This property is only used for windows.

By default, if no title has been set, this property contains an empty string.

Definition at line 83 of file qgraphicswidget.h.


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