QtBase  v6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member 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:
Inheritance graph
[legend]
Collaboration diagram for QGraphicsWidget:
Collaboration graph
[legend]

Public Types

enum  { Type = 11 }
 
- Public Types inherited from QGraphicsItem
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 , ItemContainsChildrenInShape = 0x80000
}
 
enum  GraphicsItemChange {
  ItemPositionChange , ItemVisibleChange = 2 , 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
}
 
enum  CacheMode { NoCache , ItemCoordinateCache , DeviceCoordinateCache }
 
enum  PanelModality { NonModal , PanelModal , SceneModal }
 
enum  { Type = 1 , UserType = 65536 }
 

Public Slots

bool close ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Signals

void geometryChanged ()
 
void layoutChanged ()
 
- Signals inherited from QGraphicsObject
void parentChanged ()
 
void opacityChanged ()
 
void visibleChanged ()
 
void enabledChanged ()
 
void xChanged ()
 
void yChanged ()
 
void zChanged ()
 
void rotationChanged ()
 
void scaleChanged ()
 
void childrenChanged ()
 
void widthChanged ()
 
void heightChanged ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QGraphicsWidget (QGraphicsItem *parent=nullptr, Qt::WindowFlags wFlags=Qt::WindowFlags())
 
 ~QGraphicsWidget ()
 
QGraphicsLayoutlayout () const
 
void setLayout (QGraphicsLayout *layout)
 
void adjustSize ()
 
Qt::LayoutDirection layoutDirection () const
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void unsetLayoutDirection ()
 
QStylestyle () const
 
void setStyle (QStyle *style)
 
QFont font () const
 
void setFont (const QFont &font)
 
QPalette palette () const
 
void setPalette (const QPalette &palette)
 
bool autoFillBackground () const
 
void setAutoFillBackground (bool enabled)
 
void resize (const QSizeF &size)
 
void resize (qreal w, qreal h)
 
QSizeF size () const
 
void setGeometry (const QRectF &rect) override
 
void setGeometry (qreal x, qreal y, qreal w, qreal h)
 
QRectF rect () const
 
void setContentsMargins (qreal left, qreal top, qreal right, qreal bottom)
 
void setContentsMargins (QMarginsF margins)
 
void getContentsMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const override
 
void setWindowFrameMargins (qreal left, qreal top, qreal right, qreal bottom)
 
void setWindowFrameMargins (QMarginsF margins)
 
void getWindowFrameMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const
 
void unsetWindowFrameMargins ()
 
QRectF windowFrameGeometry () const
 
QRectF windowFrameRect () const
 
Qt::WindowFlags windowFlags () const
 
Qt::WindowType windowType () const
 
void setWindowFlags (Qt::WindowFlags wFlags)
 
bool isActiveWindow () const
 
void setWindowTitle (const QString &title)
 
QString windowTitle () const
 
Qt::FocusPolicy focusPolicy () const
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
QGraphicsWidgetfocusWidget () const
 
int grabShortcut (const QKeySequence &sequence, Qt::ShortcutContext context=Qt::WindowShortcut)
 
void releaseShortcut (int id)
 
void setShortcutEnabled (int id, bool enabled=true)
 
void setShortcutAutoRepeat (int id, bool enabled=true)
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void insertActions (QAction *before, const QList< QAction * > &actions)
 
void insertAction (QAction *before, QAction *action)
 
void removeAction (QAction *action)
 
QList< QAction * > actions () const
 
void setAttribute (Qt::WidgetAttribute attribute, bool on=true)
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
int type () const override
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
 
virtual void paintWindowFrame (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)
 
QRectF boundingRect () const override
 
QPainterPath shape () const override
 
const QObjectListchildren () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 
- Public Member Functions inherited from QGraphicsItem
 QGraphicsItem (QGraphicsItem *parent=nullptr)
 
virtual ~QGraphicsItem ()
 
QGraphicsScenescene () const
 
QGraphicsItemparentItem () const
 
QGraphicsItemtopLevelItem () const
 
QGraphicsObjectparentObject () const
 
QGraphicsWidgetparentWidget () const
 
QGraphicsWidgettopLevelWidget () const
 
QGraphicsWidgetwindow () const
 
QGraphicsItempanel () const
 
void setParentItem (QGraphicsItem *parent)
 
QList< QGraphicsItem * > childItems () const
 
bool isWidget () const
 
bool isWindow () const
 
bool isPanel () const
 
QGraphicsObjecttoGraphicsObject ()
 
const QGraphicsObjecttoGraphicsObject () const
 
QGraphicsItemGroupgroup () const
 
void setGroup (QGraphicsItemGroup *group)
 
GraphicsItemFlags flags () const
 
void setFlag (GraphicsItemFlag flag, bool enabled=true)
 
void setFlags (GraphicsItemFlags flags)
 
CacheMode cacheMode () const
 
void setCacheMode (CacheMode mode, const QSize &cacheSize=QSize())
 
PanelModality panelModality () const
 
void setPanelModality (PanelModality panelModality)
 
bool isBlockedByModalPanel (QGraphicsItem **blockingPanel=nullptr) const
 
QCursor cursor () const
 
void setCursor (const QCursor &cursor)
 
bool hasCursor () const
 
void unsetCursor ()
 
bool isVisible () const
 
bool isVisibleTo (const QGraphicsItem *parent) const
 
void setVisible (bool visible)
 
void hide ()
 
void show ()
 
bool isEnabled () const
 
void setEnabled (bool enabled)
 
bool isSelected () const
 
void setSelected (bool selected)
 
bool acceptDrops () const
 
void setAcceptDrops (bool on)
 
qreal opacity () const
 
qreal effectiveOpacity () const
 
void setOpacity (qreal opacity)
 
Qt::MouseButtons acceptedMouseButtons () const
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 
bool acceptHoverEvents () const
 
void setAcceptHoverEvents (bool enabled)
 
bool acceptTouchEvents () const
 
void setAcceptTouchEvents (bool enabled)
 
bool filtersChildEvents () const
 
void setFiltersChildEvents (bool enabled)
 
bool handlesChildEvents () const
 
void setHandlesChildEvents (bool enabled)
 
bool isActive () const
 
void setActive (bool active)
 
bool hasFocus () const
 
void setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason)
 
void clearFocus ()
 
QGraphicsItemfocusProxy () const
 
void setFocusProxy (QGraphicsItem *item)
 
QGraphicsItemfocusItem () const
 
QGraphicsItemfocusScopeItem () const
 
void grabMouse ()
 
void ungrabMouse ()
 
void grabKeyboard ()
 
void ungrabKeyboard ()
 
QPointF pos () const
 
qreal x () const
 
void setX (qreal x)
 
qreal y () const
 
void setY (qreal y)
 
QPointF scenePos () const
 
void setPos (const QPointF &pos)
 
void setPos (qreal x, qreal y)
 
void moveBy (qreal dx, qreal dy)
 
void ensureVisible (const QRectF &rect=QRectF(), int xmargin=50, int ymargin=50)
 
void ensureVisible (qreal x, qreal y, qreal w, qreal h, int xmargin=50, int ymargin=50)
 
QTransform transform () const
 
QTransform sceneTransform () const
 
QTransform deviceTransform (const QTransform &viewportTransform) const
 
QTransform itemTransform (const QGraphicsItem *other, bool *ok=nullptr) const
 
void setTransform (const QTransform &matrix, bool combine=false)
 
void resetTransform ()
 
void setRotation (qreal angle)
 
qreal rotation () const
 
void setScale (qreal scale)
 
qreal scale () const
 
QList< QGraphicsTransform * > transformations () const
 
void setTransformations (const QList< QGraphicsTransform * > &transformations)
 
QPointF transformOriginPoint () const
 
void setTransformOriginPoint (const QPointF &origin)
 
void setTransformOriginPoint (qreal ax, qreal ay)
 
virtual void advance (int phase)
 
qreal zValue () const
 
void setZValue (qreal z)
 
void stackBefore (const QGraphicsItem *sibling)
 
QRectF childrenBoundingRect () const
 
QRectF sceneBoundingRect () const
 
bool isClipped () const
 
QPainterPath clipPath () const
 
virtual bool contains (const QPointF &point) const
 
virtual bool collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 
virtual bool collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 
QList< QGraphicsItem * > collidingItems (Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 
bool isObscured (const QRectF &rect=QRectF()) const
 
bool isObscured (qreal x, qreal y, qreal w, qreal h) const
 
virtual bool isObscuredBy (const QGraphicsItem *item) const
 
virtual QPainterPath opaqueArea () const
 
QRegion boundingRegion (const QTransform &itemToDeviceTransform) const
 
qreal boundingRegionGranularity () const
 
void setBoundingRegionGranularity (qreal granularity)
 
void update (const QRectF &rect=QRectF())
 
void update (qreal x, qreal y, qreal width, qreal height)
 
void scroll (qreal dx, qreal dy, const QRectF &rect=QRectF())
 
QPointF mapToItem (const QGraphicsItem *item, const QPointF &point) const
 
QPointF mapToParent (const QPointF &point) const
 
QPointF mapToScene (const QPointF &point) const
 
QPolygonF mapToItem (const QGraphicsItem *item, const QRectF &rect) const
 
QPolygonF mapToParent (const QRectF &rect) const
 
QPolygonF mapToScene (const QRectF &rect) const
 
QRectF mapRectToItem (const QGraphicsItem *item, const QRectF &rect) const
 
QRectF mapRectToParent (const QRectF &rect) const
 
QRectF mapRectToScene (const QRectF &rect) const
 
QPolygonF mapToItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 
QPolygonF mapToParent (const QPolygonF &polygon) const
 
QPolygonF mapToScene (const QPolygonF &polygon) const
 
QPainterPath mapToItem (const QGraphicsItem *item, const QPainterPath &path) const
 
QPainterPath mapToParent (const QPainterPath &path) const
 
QPainterPath mapToScene (const QPainterPath &path) const
 
QPointF mapFromItem (const QGraphicsItem *item, const QPointF &point) const
 
QPointF mapFromParent (const QPointF &point) const
 
QPointF mapFromScene (const QPointF &point) const
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QRectF &rect) const
 
QPolygonF mapFromParent (const QRectF &rect) const
 
QPolygonF mapFromScene (const QRectF &rect) const
 
QRectF mapRectFromItem (const QGraphicsItem *item, const QRectF &rect) const
 
QRectF mapRectFromParent (const QRectF &rect) const
 
QRectF mapRectFromScene (const QRectF &rect) const
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 
QPolygonF mapFromParent (const QPolygonF &polygon) const
 
QPolygonF mapFromScene (const QPolygonF &polygon) const
 
QPainterPath mapFromItem (const QGraphicsItem *item, const QPainterPath &path) const
 
QPainterPath mapFromParent (const QPainterPath &path) const
 
QPainterPath mapFromScene (const QPainterPath &path) const
 
QPointF mapToItem (const QGraphicsItem *item, qreal x, qreal y) const
 
QPointF mapToParent (qreal x, qreal y) const
 
QPointF mapToScene (qreal x, qreal y) const
 
QPolygonF mapToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapToParent (qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapToScene (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToParent (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToScene (qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapFromItem (const QGraphicsItem *item, qreal x, qreal y) const
 
QPointF mapFromParent (qreal x, qreal y) const
 
QPointF mapFromScene (qreal x, qreal y) const
 
QPolygonF mapFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapFromParent (qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapFromScene (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromParent (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromScene (qreal x, qreal y, qreal w, qreal h) const
 
bool isAncestorOf (const QGraphicsItem *child) const
 
QGraphicsItemcommonAncestorItem (const QGraphicsItem *other) const
 
bool isUnderMouse () const
 
QVariant data (int key) const
 
void setData (int key, const QVariant &value)
 
Qt::InputMethodHints inputMethodHints () const
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void installSceneEventFilter (QGraphicsItem *filterItem)
 
void removeSceneEventFilter (QGraphicsItem *filterItem)
 
- Public Member Functions inherited from QGraphicsLayoutItem
 QGraphicsLayoutItem (QGraphicsLayoutItem *parent=nullptr, bool isLayout=false)
 
virtual ~QGraphicsLayoutItem ()
 
void setSizePolicy (const QSizePolicy &policy)
 
void setSizePolicy (QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType=QSizePolicy::DefaultType)
 
QSizePolicy sizePolicy () const
 
void setMinimumSize (const QSizeF &size)
 
void setMinimumSize (qreal w, qreal h)
 
QSizeF minimumSize () const
 
void setMinimumWidth (qreal width)
 
qreal minimumWidth () const
 
void setMinimumHeight (qreal height)
 
qreal minimumHeight () const
 
void setPreferredSize (const QSizeF &size)
 
void setPreferredSize (qreal w, qreal h)
 
QSizeF preferredSize () const
 
void setPreferredWidth (qreal width)
 
qreal preferredWidth () const
 
void setPreferredHeight (qreal height)
 
qreal preferredHeight () const
 
void setMaximumSize (const QSizeF &size)
 
void setMaximumSize (qreal w, qreal h)
 
QSizeF maximumSize () const
 
void setMaximumWidth (qreal width)
 
qreal maximumWidth () const
 
void setMaximumHeight (qreal height)
 
qreal maximumHeight () const
 
QRectF geometry () const
 
QRectF contentsRect () const
 
QSizeF effectiveSizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 
virtual bool isEmpty () const
 
QGraphicsLayoutItemparentLayoutItem () const
 
void setParentLayoutItem (QGraphicsLayoutItem *parent)
 
bool isLayout () const
 
QGraphicsItemgraphicsItem () const
 
bool ownedByLayout () const
 

Static Public Member Functions

static void setTabOrder (QGraphicsWidget *first, QGraphicsWidget *second)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Protected Member Functions

virtual void initStyleOption (QStyleOption *option) const
 
QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const override
 
void updateGeometry () override
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
 
virtual QVariant propertyChange (const QString &propertyName, const QVariant &value)
 
bool sceneEvent (QEvent *event) override
 
virtual bool windowFrameEvent (QEvent *e)
 
virtual Qt::WindowFrameSection windowFrameSectionAt (const QPointF &pos) const
 
bool event (QEvent *event) override
 
virtual void changeEvent (QEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
void focusInEvent (QFocusEvent *event) override
 
virtual bool focusNextPrevChild (bool next)
 
void focusOutEvent (QFocusEvent *event) override
 
virtual void hideEvent (QHideEvent *event)
 
virtual void moveEvent (QGraphicsSceneMoveEvent *event)
 
virtual void polishEvent ()
 
virtual void resizeEvent (QGraphicsSceneResizeEvent *event)
 
virtual void showEvent (QShowEvent *event)
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event) override
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 
virtual void grabMouseEvent (QEvent *event)
 
virtual void ungrabMouseEvent (QEvent *event)
 
virtual void grabKeyboardEvent (QEvent *event)
 
virtual void ungrabKeyboardEvent (QEvent *event)
 
 QGraphicsWidget (QGraphicsWidgetPrivate &, QGraphicsItem *parent, Qt::WindowFlags wFlags=Qt::WindowFlags())
 
- Protected Member Functions inherited from QGraphicsObject
 QGraphicsObject (QGraphicsItemPrivate &dd, QGraphicsItem *parent)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QGraphicsItem
void updateMicroFocus ()
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 
virtual void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dropEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
virtual bool supportsExtension (Extension extension) const
 
virtual void setExtension (Extension extension, const QVariant &variant)
 
virtual QVariant extension (const QVariant &variant) const
 
 QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent)
 
void addToIndex ()
 
void removeFromIndex ()
 
void prepareGeometryChange ()
 
- Protected Member Functions inherited from QGraphicsLayoutItem
void setGraphicsItem (QGraphicsItem *item)
 
void setOwnedByLayout (bool ownedByLayout)
 
 QGraphicsLayoutItem (QGraphicsLayoutItemPrivate &dd)
 

Properties

QPalette palette
 the widget's palette More...
 
QFont font
 the widgets' font More...
 
Qt::LayoutDirection layoutDirection
 the layout direction for this widget. More...
 
QSizeF size
 the size of the widget More...
 
QSizeF minimumSize
 the minimum size of the widget More...
 
QSizeF preferredSize
 the preferred size of the widget More...
 
QSizeF maximumSize
 the maximum size of the widget More...
 
QSizePolicy sizePolicy
 the size policy for the widget More...
 
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus More...
 
Qt::WindowFlags windowFlags
 the widget's window flags More...
 
QString windowTitle
 This property holds the window title (caption). More...
 
QRectF geometry
 the geometry of the widget More...
 
bool autoFillBackground
 whether the widget background is filled automatically More...
 
QGraphicsLayoutlayout
 The layout of the widget. More...
 
- Properties inherited from QGraphicsObject
QGraphicsObjectparent
 the parent of the item More...
 
qreal opacity
 the opacity of the item More...
 
bool enabled
 whether the item is enabled or not More...
 
bool visible
 whether the item is visible or not More...
 
QPointF pos
 the position of the item More...
 
qreal x
 the x position of the item More...
 
qreal y
 the y position of the item More...
 
qreal z
 the z value of the item More...
 
qreal rotation
 the rotation of the item in degrees. More...
 
qreal scale
 the scale of the item. More...
 
QPointF transformOriginPoint
 the transformation origin More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

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

Additional Inherited Members

- Protected Types inherited from QGraphicsItem
enum  Extension { UserExtension = 0x80000000 }
 
- Protected Slots inherited from QGraphicsObject
void updateMicroFocus ()
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Attributes inherited from QGraphicsItem
QScopedPointer< QGraphicsItemPrivated_ptr
 
- Protected Attributes inherited from QGraphicsLayoutItem
QScopedPointer< QGraphicsLayoutItemPrivated_ptr
 

Detailed Description

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

Since
4.4

\inmodule QtWidgets

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

\list

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:

\table \header

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.

\table \header

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 \nullptr for QGraphicsWidgets, but this policy is not strictly defined.
See also
QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}

Definition at line 67 of file qgraphicswidget.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 162 of file qgraphicswidget.h.

Constructor & Destructor Documentation

◆ QGraphicsWidget() [1/2]

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

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 176 of file qgraphicswidget.cpp.

◆ ~QGraphicsWidget()

QGraphicsWidget::~QGraphicsWidget ( )

Destroys the QGraphicsWidget instance.

Definition at line 231 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ QGraphicsWidget() [2/2]

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

Definition at line 188 of file qgraphicswidget.cpp.

Member Function Documentation

◆ actions()

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

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

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

Definition at line 2097 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ addAction()

void QGraphicsWidget::addAction ( QAction action)
Since
4.5

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

All QGraphicsWidgets have a list of \l{QAction}s, 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 1991 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ addActions()

void QGraphicsWidget::addActions ( const QList< QAction * > &  actions)
Since
4.5

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

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

Definition at line 2003 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ 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 858 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ autoFillBackground()

bool QGraphicsWidget::autoFillBackground ( ) const

Definition at line 1043 of file qgraphicswidget.cpp.

◆ boundingRect()

QRectF QGraphicsWidget::boundingRect ( ) const
overridevirtual

\reimp

Implements QGraphicsItem.

Reimplemented in TopBar.

Definition at line 2349 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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

Reimplemented in TestWidget, Widget, and Widget.

Definition at line 1484 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ children()

const QObjectList & QObject::children
inline

Returns a list of child objects. The QObjectList class is defined in the {<QObject>} header file as the following:

\quotefromfile kernel/qobject.h \skipto /typedef .*QObjectList/ \printuntil QObjectList

The first child added is the \l{QList::first()}{first} object in the list and the last child added is the \l{QList::last()}{last} object in the list, i.e. new children are appended at the end.

Note that the list order changes when QWidget children are \l{QWidget::raise()}{raised} or \l{QWidget::lower()}{lowered}. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list.

See also
findChild(), findChildren(), parent(), setParent()

Definition at line 206 of file qobject.h.

Here is the caller graph for this function:

◆ 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 2375 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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

Reimplemented in Window, and Widget.

Definition at line 1517 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ event()

bool QGraphicsWidget::event ( QEvent event)
overrideprotectedvirtual

\reimp

Handles the event. QGraphicsWidget handles the following events:

\table \header

  • Event
  • Usage \row
  • Polish
  • Delivered to the widget some time after it has been shown. \row
  • GraphicsSceneMove
  • Delivered to the widget after its local position has changed. \row
  • GraphicsSceneResize
  • Delivered to the widget after its size has changed. \row
  • Show
  • Delivered to the widget before it has been shown. \row
  • Hide
  • Delivered to the widget after it has been hidden. \row
  • PaletteChange
  • Delivered to the widget after its palette has changed. \row
  • FontChange
  • Delivered to the widget after its font has changed. \row
  • EnabledChange
  • Delivered to the widget after its enabled state has changed. \row
  • StyleChange
  • Delivered to the widget after its style has changed. \row
  • LayoutDirectionChange
  • Delivered to the widget after its layout direction has changed. \row
  • ContentsRectChange
  • Delivered to the widget after its contents margins/ contents rect has changed. \endtable

Reimplemented from QGraphicsObject.

Reimplemented in Window, TestWidget, SubQGraphicsWidget, ReuseCanceledGesturesWidget, Window, Window, Widget, FocusWidget, TestGraphicsWidget, SlowWidget, AbstractViewItem, AbstractScrollArea, AbstractItemView, AbstractItemContainer, Window, Window, and Window.

Definition at line 1383 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusInEvent()

void QGraphicsWidget::focusInEvent ( QFocusEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Reimplemented in FocusWatchWidget, FocusWidget, and FocusWidget.

Definition at line 1525 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1551 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusOutEvent()

void QGraphicsWidget::focusOutEvent ( QFocusEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Reimplemented in FocusWatchWidget, SubQGraphicsProxyWidget, FocusWidget, Widget, and FocusWidget.

Definition at line 1573 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusPolicy()

Qt::FocusPolicy QGraphicsWidget::focusPolicy ( ) const

Definition at line 1847 of file qgraphicswidget.cpp.

◆ 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, \nullptr is returned.

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

Definition at line 1870 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ font()

QFont QGraphicsWidget::font ( ) const

Definition at line 970 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ geometryChanged

QGraphicsWidget::geometryChanged ( )
signal

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

◆ getContentsMargins()

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

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

See also
setContentsMargins()

Reimplemented from QGraphicsLayoutItem.

Definition at line 526 of file qgraphicswidget.cpp.

◆ 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 \nullptr.

See also
setWindowFrameMargins(), windowFrameRect()

Definition at line 585 of file qgraphicswidget.cpp.

◆ 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 1714 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1692 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grabShortcut()

int QGraphicsWidget::grabShortcut ( const QKeySequence sequence,
Qt::ShortcutContext  context = Qt::WindowShortcut 
)
Since
4.5

Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. 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 \l{QAction}s with the shortcut key sequences you require (if you also want equivalent menu options and toolbar buttons), or create \l{QShortcut}s 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 1906 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ hideEvent()

void QGraphicsWidget::hideEvent ( QHideEvent event)
protectedvirtual

This event handler, for \l{QEvent::Hide}{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, and Widget.

Definition at line 1592 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hoverLeaveEvent()

void QGraphicsWidget::hoverLeaveEvent ( QGraphicsSceneHoverEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Reimplemented in QGraphicsProxyWidget, and CustomProxy.

Definition at line 1681 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ hoverMoveEvent()

void QGraphicsWidget::hoverMoveEvent ( QGraphicsSceneHoverEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Reimplemented in QGraphicsProxyWidget.

Definition at line 1673 of file qgraphicswidget.cpp.

Here is the call graph for this function:

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

\table \header

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:

See also
QStyleOption::initFrom()

Reimplemented in SubQGraphicsWidget.

Definition at line 693 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertAction()

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

Inserts the action action to this widget's list of actions, before the action before. It appends the action if before is \nullptr 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 2021 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertActions()

void QGraphicsWidget::insertActions ( QAction before,
const QList< QAction * > &  actions 
)
Since
4.5

Inserts the actions actions to this widget's list of actions, before the action before. It appends the action if before is \nullptr 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 2060 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ 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 1801 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemChange()

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

\reimp

QGraphicsWidget uses the base implementation of this function to catch and deliver events related to state changes in the item. 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 \l{QEvent::Show} {Show} and \l{QEvent::Hide}{Hide} events, ItemPositionHasChanged to deliver \l{QEvent::Move}{Move} events, and ItemParentChange both to deliver \l{QEvent::ParentChange} {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.

Reimplemented in ItemChangeTester, MyGraphicsItemWithItemChange, ItemChangeTester, and AbstractItemContainer.

Definition at line 1120 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layout()

QGraphicsLayout * QGraphicsWidget::layout ( ) const

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

See also
setLayout()

Definition at line 800 of file qgraphicswidget.cpp.

◆ layoutChanged

void QGraphicsWidget::layoutChanged ( )
signal

This signal gets emitted whenever the layout of the item changes

Here is the caller graph for this function:

◆ layoutDirection()

Qt::LayoutDirection QGraphicsWidget::layoutDirection ( ) const

Definition at line 892 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ moveEvent()

void QGraphicsWidget::moveEvent ( QGraphicsSceneMoveEvent event)
protectedvirtual

This event handler, for \l{QEvent::GraphicsSceneMove}{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 1614 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ paint()

void QGraphicsWidget::paint ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget = nullptr 
)
overridevirtual

◆ paintWindowFrame()

void QGraphicsWidget::paintWindowFrame ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget = nullptr 
)
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()

Reimplemented in MessUpPainterWidget, and CustomProxy.

Definition at line 2251 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ palette()

QPalette QGraphicsWidget::palette ( ) const

Definition at line 1012 of file qgraphicswidget.cpp.

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

Reimplemented in PolishWidget.

Definition at line 1628 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ propertyChange()

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

Definition at line 1212 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 115 of file qgraphicswidget.h.

Here is the caller graph for this function:

◆ releaseShortcut()

void QGraphicsWidget::releaseShortcut ( int  id)
Since
4.5

Removes the shortcut with the given id from Qt's shortcut system. 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 1932 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ removeAction()

void QGraphicsWidget::removeAction ( QAction action)
Since
4.5

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

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

Definition at line 2073 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ resize() [1/2]

void QGraphicsWidget::resize ( const QSizeF size)

Definition at line 312 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Constructs a resize with the given width (w) and height (h). This convenience function is equivalent to calling resize(QSizeF(w, h)).

See also
setGeometry(), setTransform()

Definition at line 110 of file qgraphicswidget.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resizeEvent()

void QGraphicsWidget::resizeEvent ( QGraphicsSceneResizeEvent event)
protectedvirtual

This event handler, for \l{QEvent::GraphicsSceneResize}{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, PlaceWidget, TopBar, SimpleListView, RecycledListItem, ListWidget, and BackgroundItem.

Definition at line 1648 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sceneEvent()

bool QGraphicsWidget::sceneEvent ( QEvent event)
overrideprotectedvirtual

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.

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

See also
QGraphicsItem::sceneEvent()

Reimplemented from QGraphicsItem.

Reimplemented in FocusWidget.

Definition at line 1229 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 2193 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ setAutoFillBackground()

void QGraphicsWidget::setAutoFillBackground ( bool  enabled)

Definition at line 1048 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setContentsMargins() [1/2]

void QGraphicsWidget::setContentsMargins ( QMarginsF  margins)
Since
5.14

Sets the widget's contents margins to margins.

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 \l{QEvent::ContentsRectChange}{ContentsRectChange} event.

See also
getContentsMargins(), setGeometry()

Definition at line 487 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setContentsMargins() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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

Definition at line 514 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ setFocusPolicy()

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

Definition at line 1852 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFont()

void QGraphicsWidget::setFont ( const QFont font)

Definition at line 977 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGeometry() [1/2]

void QGraphicsWidget::setGeometry ( const QRectF rect)
overridevirtual

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.

Reimplemented in RectWidget, TestGraphicsWidget, and SlowWidget.

Definition at line 353 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 239 of file qgraphicswidget.h.

Here is the call graph for this function:

◆ 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 \nullptr, 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 825 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLayoutDirection()

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

Definition at line 896 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setPalette()

void QGraphicsWidget::setPalette ( const QPalette palette)

Definition at line 1017 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setShortcutAutoRepeat()

void QGraphicsWidget::setShortcutAutoRepeat ( int  id,
bool  enabled = true 
)
Since
4.5

If enabled is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled.

See also
grabShortcut(), releaseShortcut(), QWidget::setShortcutAutoRepeat()

Definition at line 1968 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setShortcutEnabled()

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

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

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 1953 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ 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 \nullptr, 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 \nullptr; otherwise it clears the attribute.

See also
style()

Definition at line 938 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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:

not like this:

If first is \nullptr, 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 \nullptr, 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 in Widgets}

Definition at line 2128 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setWindowFlags()

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

Definition at line 1762 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setWindowFrameMargins() [1/2]

void QGraphicsWidget::setWindowFrameMargins ( QMarginsF  margins)
Since
5.14 Sets the widget's window frame margins to margins. 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 552 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ setWindowFrameMargins() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the widget's window frame margins to left, top, right and bottom.

Definition at line 573 of file qgraphicswidget.cpp.

◆ setWindowTitle()

void QGraphicsWidget::setWindowTitle ( const QString title)

Definition at line 1815 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ shape()

QPainterPath QGraphicsWidget::shape ( ) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 2357 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showEvent()

void QGraphicsWidget::showEvent ( QShowEvent event)
protectedvirtual

This event handler, for \l{QEvent::Show}{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 1665 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

QSizeF QGraphicsWidget::size ( ) const

Definition at line 307 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ sizeHint()

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

\reimp

Implements QGraphicsLayoutItem.

Reimplemented in MySquareWidget, HFWWidget, SizeHinter, RectWidget, CustomGraphicsWidget, RectWidget, TestWidget, and SimpleListView.

Definition at line 736 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ 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 917 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 2208 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ type()

int QGraphicsWidget::type ( ) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 2225 of file qgraphicswidget.cpp.

◆ 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 1725 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1703 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unsetLayoutDirection()

void QGraphicsWidget::unsetLayoutDirection ( )

Definition at line 902 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ 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 605 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGeometry()

void QGraphicsWidget::updateGeometry ( )
overrideprotectedvirtual

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 1066 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ windowFlags()

Qt::WindowFlags QGraphicsWidget::windowFlags ( ) const

Definition at line 1757 of file qgraphicswidget.cpp.

◆ 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 1247 of file qgraphicswidget.cpp.

Here is the caller graph for this function:

◆ 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 628 of file qgraphicswidget.cpp.

Here is the call graph for this function:

◆ windowFrameRect()

QRectF QGraphicsWidget::windowFrameRect ( ) const

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

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

Definition at line 642 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ windowFrameSectionAt()

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

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

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

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

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

Definition at line 1294 of file qgraphicswidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ windowTitle()

QString QGraphicsWidget::windowTitle ( ) const

Definition at line 1821 of file qgraphicswidget.cpp.

◆ windowType()

Qt::WindowType QGraphicsWidget::windowType ( ) const

Returns the widgets window type.

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

Definition at line 1735 of file qgraphicswidget.cpp.

Friends And Related Function Documentation

◆ QApplication

friend class QApplication
friend

Definition at line 236 of file qgraphicswidget.h.

◆ QGraphicsItem

friend class QGraphicsItem
friend

Definition at line 232 of file qgraphicswidget.h.

◆ QGraphicsItemPrivate

friend class QGraphicsItemPrivate
friend

Definition at line 233 of file qgraphicswidget.h.

◆ QGraphicsLayout

friend class QGraphicsLayout
friend

Definition at line 234 of file qgraphicswidget.h.

◆ QGraphicsScene

friend class QGraphicsScene
friend

Definition at line 229 of file qgraphicswidget.h.

◆ QGraphicsScenePrivate

friend class QGraphicsScenePrivate
friend

Definition at line 230 of file qgraphicswidget.h.

◆ QGraphicsView

friend class QGraphicsView
friend

Definition at line 231 of file qgraphicswidget.h.

◆ QWidget

friend class QWidget
friend

Definition at line 235 of file qgraphicswidget.h.

Property Documentation

◆ autoFillBackground

QGraphicsWidget::autoFillBackground
readwrite

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 \l{QPalette}{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 242 of file qgraphicswidget.h.

◆ focusPolicy

QGraphicsWidget::focusPolicy
readwrite

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 242 of file qgraphicswidget.h.

◆ font

QGraphicsWidget::font
readwrite

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 \l{QEvent::FontChange}{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 242 of file qgraphicswidget.h.

◆ geometry

QGraphicsWidget::geometry
readwrite

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 242 of file qgraphicswidget.h.

◆ layout

QGraphicsWidget::layout
readwrite

The layout of the widget.

Any existing layout manager is deleted before the new layout is assigned. If layout is \nullptr, 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 \nullptr.

Definition at line 242 of file qgraphicswidget.h.

◆ layoutDirection

QGraphicsWidget::layoutDirection
readwrite

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 \l{QEvent::LayoutDirectionChange}{LayoutDirectionChange} event, and then propagate the new layout direction to all its descendants.

See also
QWidget::layoutDirection, QApplication::layoutDirection

Definition at line 242 of file qgraphicswidget.h.

◆ maximumSize

QGraphicsWidget::maximumSize
readwrite

the maximum size of the widget

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

Definition at line 242 of file qgraphicswidget.h.

◆ minimumSize

QGraphicsWidget::minimumSize
readwrite

the minimum size of the widget

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

Definition at line 242 of file qgraphicswidget.h.

◆ palette

QGraphicsWidget::palette
readwrite

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 \l{QEvent::PaletteChange}{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
QGuiApplication::palette(), QGraphicsScene::palette, QPalette::resolve()

Definition at line 242 of file qgraphicswidget.h.

◆ preferredSize

QGraphicsWidget::preferredSize
readwrite

the preferred size of the widget

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

Definition at line 242 of file qgraphicswidget.h.

◆ size

QGraphicsWidget::size
readwrite

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 \l{QEvent::GraphicsSceneResize}{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 242 of file qgraphicswidget.h.

◆ sizePolicy

QGraphicsWidget::sizePolicy
readwrite

the size policy for the widget

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

Definition at line 242 of file qgraphicswidget.h.

◆ windowFlags

QGraphicsWidget::windowFlags
readwrite

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 242 of file qgraphicswidget.h.

◆ windowTitle

QGraphicsWidget::windowTitle
readwrite

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 242 of file qgraphicswidget.h.


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