diff options
Diffstat (limited to 'src/widgets/graphicsview/qgraphicslayoutitem.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicslayoutitem.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp index 8694dcb36b..2c484321e4 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp @@ -45,6 +45,7 @@ #include "qgraphicslayoutitem_p.h" #include "qwidget.h" #include "qgraphicswidget.h" +#include "qgraphicsitem_p.h" #include <QtDebug> @@ -826,6 +827,22 @@ void QGraphicsLayoutItem::updateGeometry() } /*! + * returns \c true if this item is empty, i.e whether it has no content and + * should not occupy any space. + * + * The default implementation returns true if the item has been hidden unless + * its size policy has retainSizeWhenHidden set to \c true + */ +bool QGraphicsLayoutItem::isEmpty() const +{ + bool isHidden = false; + if (QGraphicsItem *item = graphicsItem()) + isHidden = QGraphicsItemPrivate::get(item)->explicitlyHidden; + + return isHidden && !sizePolicy().retainSizeWhenHidden(); +} + +/*! Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with |