From 4d4eb11fe340bf0b3a1ce0caae62d9319bf941cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 7 May 2021 11:38:24 +0200 Subject: Improve handling of minimumHeightForWidth() This also aligns the implementation with QWidgetItem::heightForWidth() Fixes: QTBUG-92599 Pick-to: 5.15 6.1 Change-Id: I0de68c61ec37a16a8c338575d07ff9e8168a0b98 Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qlayout.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/widgets/kernel/qlayout.cpp') diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 39c7f7ec3f..8688e011a0 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -604,6 +604,28 @@ void QLayout::childEvent(QChildEvent *e) removeItem(childLayout); } +/*! + \internal + Also takes contentsMargins and menu bar into account. +*/ +int QLayout::totalMinimumHeightForWidth(int w) const +{ + Q_D(const QLayout); + int side=0, top=0; + if (d->topLevel) { + QWidget *parent = parentWidget(); + parent->ensurePolished(); + QWidgetPrivate *wd = parent->d_func(); + side += wd->leftmargin + wd->rightmargin; + top += wd->topmargin + wd->bottommargin; + } + int h = minimumHeightForWidth(w - side) + top; +#if QT_CONFIG(menubar) + h += menuBarHeightForWidth(d->menubar, w); +#endif + return h; +} + /*! \internal Also takes contentsMargins and menu bar into account. -- cgit v1.2.3