From 1b90684948df45977515ab5e9a3fb4aafb72c6fd Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 27 Jan 2019 17:49:07 +0100 Subject: QtWidgets: replace 0 with \nullptr in documentation Replace 0 with \nullptr in the documentation. As a drive-by also replace some 0 with nullptr in the corresponding code. Change-Id: I5e5bc1ae892f270d7c3419db1c179053561f1b26 Reviewed-by: Paul Wicking --- src/widgets/kernel/qlayoutitem.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/widgets/kernel/qlayoutitem.cpp') diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 25890e888b..9e6d1c5eac 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; } /*! -- cgit v1.2.3 From d0f016ebfb86fcebcf72c37c489260a0d02147e7 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 19 Mar 2019 17:31:56 +0100 Subject: Ensure that layouts don't move widgets outside of their parent When using a style that wants to draw into the layout's margin (like macOS style does with group box titles), parts of the widgets would be clipped by the parent if the available margin is smaller than necessary. This moves the x/y coordinates to at least 0/0, and adjusts width and height accordingly. [ChangeLog][QtWidgets][QLayout] Prevent clipping of group box titles on macOS (and similar styles that draw into layout margins) Change-Id: I32148a92858c13fb2325da4d0a2a58996e0e8930 Fixes: QTBUG-67608 Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qlayoutitem.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/widgets/kernel/qlayoutitem.cpp') diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 9e6d1c5eac..0aab0bb06d 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -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()); } -- cgit v1.2.3