QLayout: Observe contents margin when positioning the menu bar.
Task-number: QTBUG-38152 Change-Id: I53ea6bce33057251265a7eca1651aeabca314ba9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
This commit is contained in:
parent
4958cadeda
commit
03c4b52e13
@ -576,11 +576,12 @@ void QLayoutPrivate::doResize(const QSize &r)
|
|||||||
int mbh = menuBarHeightForWidth(menubar, r.width());
|
int mbh = menuBarHeightForWidth(menubar, r.width());
|
||||||
QWidget *mw = q->parentWidget();
|
QWidget *mw = q->parentWidget();
|
||||||
QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
|
QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
|
||||||
|
const int mbTop = rect.top();
|
||||||
rect.setTop(rect.top() + mbh);
|
rect.setTop(rect.top() + mbh);
|
||||||
q->setGeometry(rect);
|
q->setGeometry(rect);
|
||||||
#ifndef QT_NO_MENUBAR
|
#ifndef QT_NO_MENUBAR
|
||||||
if (menubar)
|
if (menubar)
|
||||||
menubar->setGeometry(0,0,r.width(), mbh);
|
menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,6 +780,9 @@ void tst_QMainWindow::contentsMargins()
|
|||||||
mw.show();
|
mw.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&mw));
|
QVERIFY(QTest::qWaitForWindowExposed(&mw));
|
||||||
|
|
||||||
|
QCOMPARE(mw.menuBar()->geometry().left(), contentsMargin);
|
||||||
|
QCOMPARE(mw.menuBar()->geometry().top(), contentsMargin);
|
||||||
|
|
||||||
QCOMPARE(mw.statusBar()->geometry().left(), contentsMargin);
|
QCOMPARE(mw.statusBar()->geometry().left(), contentsMargin);
|
||||||
QCOMPARE(mw.statusBar()->geometry().bottom() + 1, mw.height() - contentsMargin);
|
QCOMPARE(mw.statusBar()->geometry().bottom() + 1, mw.height() - contentsMargin);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user