summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-09-10 08:31:35 +0200
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2014-10-22 07:23:37 +0200
commitbd4a19963e102f4a89fdc1f17349909605324519 (patch)
tree249beba226d24b1d40d44499a72e3fc9a051f949
parentc5bc66df2fd976f4e055c579f6918138d3accd87 (diff)
Respect contents margins when calculating the size hint
Without this part of the calendar widget get cut off when put in a layout and the contentsMargins are non zero. Task-number: QTBUG-40352 Change-Id: I9ce90476c59c270d92e876a5dc81ea8ce325848c Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp3
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp10
2 files changed, 13 insertions, 0 deletions
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index d6704c20d2..fa3dbc1f32 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -2247,6 +2247,9 @@ QSize QCalendarWidget::minimumSizeHint() const
w *= cols;
w = qMax(headerSize.width(), w);
h = (h * rows) + headerSize.height();
+ QMargins cm = contentsMargins();
+ w += cm.left() + cm.right();
+ h += cm.top() + cm.bottom();
d->cachedSizeHint = QSize(w, h);
return d->cachedSizeHint;
}
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
index e3e7b13cbe..d0a787d32a 100644
--- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -67,6 +67,8 @@ private slots:
void showPrevNext();
void firstDayOfWeek();
+
+ void contentsMargins();
};
// Testing get/set functions
@@ -391,5 +393,13 @@ void tst_QCalendarWidget::firstDayOfWeek()
QCOMPARE(calendar.firstDayOfWeek(), germanLocale.firstDayOfWeek());
}
+void tst_QCalendarWidget::contentsMargins()
+{
+ QCalendarWidget calendar1;
+ QCalendarWidget calendar2;
+ calendar2.setContentsMargins(10, 5, 20, 30);
+ QCOMPARE(calendar1.minimumSizeHint() + QSize(30, 35), calendar2.minimumSizeHint());
+}
+
QTEST_MAIN(tst_QCalendarWidget)
#include "tst_qcalendarwidget.moc"