From 5b2dfbc649a7c20a93223cd4c274a4b0fe847df8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 May 2019 21:20:37 +0200 Subject: Long live QSize(F)::grownBy/shrunkBy() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These functions tighten the integration of QMargins(F) with the rest of the geometry classes by providing a way to apply margins to sizes (and later, rects). Apply them in a few obvious cases across QtWidgets. [ChangeLog][QtCore][QSize/QSizeF] Added grownBy(QMargin(F))/shrunkBy(QMargin(F)). Change-Id: I8a549436824cdb7fb6125a8cde89d5bf02826934 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Shawn Rutledge Reviewed-by: Edward Welbourne --- src/widgets/widgets/qdockwidget.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/widgets/widgets/qdockwidget.cpp') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 28a7cee2a0..a7010f9260 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -381,11 +381,10 @@ QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) co if (content.height() < 0) result.setHeight(-1); - int left, top, right, bottom; - w->getContentsMargins(&left, &top, &right, &bottom); + const QMargins margins = w->contentsMargins(); //we need to subtract the contents margin (it will be added by the caller) - QSize min = w->minimumSize() - QSize(left + right, top + bottom); - QSize max = w->maximumSize() - QSize(left + right, top + bottom); + QSize min = w->minimumSize().shrunkBy(margins); + QSize max = w->maximumSize().shrunkBy(margins); /* A floating dockwidget will automatically get its minimumSize set to the layout's minimum size + deco. We're *not* interested in this, we only take minimumSize() -- cgit v1.2.3