diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
commit | 6630937e63ae5797487b86743a7733c8ae5cc42c (patch) | |
tree | 3d53dacf6430f9099e1fb20835881205de674961 /src/widgets/kernel/qlayoutitem.cpp | |
parent | 37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff) | |
parent | c7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff) |
Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
Diffstat (limited to 'src/widgets/kernel/qlayoutitem.cpp')
-rw-r--r-- | src/widgets/kernel/qlayoutitem.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 25890e888b..0aab0bb06d 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -309,24 +309,24 @@ void QLayoutItem::invalidate() /*! If this item is a QLayout, it is returned as a QLayout; otherwise - 0 is returned. This function provides type-safe casting. + \nullptr is returned. This function provides type-safe casting. \sa spacerItem(), widget() */ -QLayout * QLayoutItem::layout() +QLayout *QLayoutItem::layout() { - return 0; + return nullptr; } /*! If this item is a QSpacerItem, it is returned as a QSpacerItem; - otherwise 0 is returned. This function provides type-safe casting. + otherwise \nullptr is returned. This function provides type-safe casting. \sa layout(), widget() */ -QSpacerItem * QLayoutItem::spacerItem() +QSpacerItem *QLayoutItem::spacerItem() { - return 0; + return nullptr; } /*! @@ -354,7 +354,7 @@ QSpacerItem * QSpacerItem::spacerItem() /*! If this item manages a QWidget, returns that widget. Otherwise, - \c nullptr is returned. + \nullptr is returned. \note While the functions layout() and spacerItem() perform casts, this function returns another object: QLayout and QSpacerItem inherit QLayoutItem, @@ -362,9 +362,9 @@ QSpacerItem * QSpacerItem::spacerItem() \sa layout(), spacerItem() */ -QWidget * QLayoutItem::widget() +QWidget *QLayoutItem::widget() { - return 0; + return nullptr; } /*! @@ -502,6 +502,17 @@ void QWidgetItem::setGeometry(const QRect &rect) else if (!(align & Qt::AlignTop)) y = y + (r.height() - s.height()) / 2; + // Make sure we don't move outside of the parent, e.g when styles demand + // surplus space that exceeds the available margins (f.ex macOS with QGroupBox) + if (x < 0) { + s.rwidth() += x; + x = 0; + } + if (y < 0) { + s.rheight() += y; + y = 0; + } + wid->setGeometry(x, y, s.width(), s.height()); } |