Take widget content margin into account for menu bar size calculation
The menu bar size calculation didn't take into account the margin of the layout content which makes said menu bar sticking out of the widget. This patch includes the margin to ensure the menu bar has the correct size. Fixes: QTBUG-76585 Change-Id: Ia2c163137fa2889f4028ee3b31766b2747d97b72 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
01ec11507d
commit
76a0f94a6d
@ -583,18 +583,18 @@ static bool removeWidgetRecursively(QLayoutItem *li, QObject *w)
|
||||
}
|
||||
|
||||
|
||||
void QLayoutPrivate::doResize(const QSize &r)
|
||||
void QLayoutPrivate::doResize()
|
||||
{
|
||||
Q_Q(QLayout);
|
||||
int mbh = menuBarHeightForWidth(menubar, r.width());
|
||||
QWidget *mw = q->parentWidget();
|
||||
QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
|
||||
const int mbh = menuBarHeightForWidth(menubar, rect.width());
|
||||
const int mbTop = rect.top();
|
||||
rect.setTop(mbTop + mbh);
|
||||
q->setGeometry(rect);
|
||||
#if QT_CONFIG(menubar)
|
||||
if (menubar)
|
||||
menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
|
||||
menubar->setGeometry(rect.left(), mbTop, rect.width(), mbh);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -613,12 +613,10 @@ void QLayout::widgetEvent(QEvent *e)
|
||||
|
||||
switch (e->type()) {
|
||||
case QEvent::Resize:
|
||||
if (d->activated) {
|
||||
QResizeEvent *r = (QResizeEvent *)e;
|
||||
d->doResize(r->size());
|
||||
} else {
|
||||
if (d->activated)
|
||||
d->doResize();
|
||||
else
|
||||
activate();
|
||||
}
|
||||
break;
|
||||
case QEvent::ChildRemoved:
|
||||
{
|
||||
@ -1116,7 +1114,7 @@ bool QLayout::activate()
|
||||
break;
|
||||
}
|
||||
|
||||
d->doResize(mw->size());
|
||||
d->doResize();
|
||||
|
||||
if (md->extra) {
|
||||
md->extra->explicitMinSize = explMin;
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
QLayoutPrivate();
|
||||
|
||||
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const;
|
||||
void doResize(const QSize &);
|
||||
void doResize();
|
||||
void reparentChildWidgets(QWidget *mw);
|
||||
bool checkWidget(QWidget *widget) const;
|
||||
bool checkLayout(QLayout *otherLayout) const;
|
||||
|
Loading…
Reference in New Issue
Block a user