summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/qworkspace.cpp15
-rw-r--r--tests/auto/qworkspace/tst_qworkspace.cpp10
2 files changed, 19 insertions, 6 deletions
diff --git a/src/gui/widgets/qworkspace.cpp b/src/gui/widgets/qworkspace.cpp
index 7180c4d..3a9b30c 100644
--- a/src/gui/widgets/qworkspace.cpp
+++ b/src/gui/widgets/qworkspace.cpp
@@ -2551,7 +2551,6 @@ QWorkspaceChild::QWorkspaceChild(QWidget* window, QWorkspace *parent, Qt::Window
this, SLOT(titleBarDoubleClicked()));
}
- setMinimumSize(128, 0);
int fw = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);
setContentsMargins(fw, fw, fw, fw);
@@ -2702,11 +2701,15 @@ QSize QWorkspaceChild::sizeHint() const
QSize QWorkspaceChild::minimumSizeHint() const
{
- if (!childWidget)
- return QWidget::minimumSizeHint() + baseSize();
- QSize s = childWidget->minimumSize();
- if (s.isEmpty())
- s = childWidget->minimumSizeHint();
+ QSize s;
+ if (!childWidget) {
+ s = QWidget::minimumSizeHint();
+ } else {
+ s = childWidget->minimumSize();
+ if (s.isEmpty())
+ s = childWidget->minimumSizeHint();
+ }
+ s = s.expandedTo(QSize(128, 0));
return s + baseSize();
}
diff --git a/tests/auto/qworkspace/tst_qworkspace.cpp b/tests/auto/qworkspace/tst_qworkspace.cpp
index 4cf76b5..9039eb3 100644
--- a/tests/auto/qworkspace/tst_qworkspace.cpp
+++ b/tests/auto/qworkspace/tst_qworkspace.cpp
@@ -44,6 +44,7 @@
#include <qapplication.h>
#include <qmainwindow.h>
#include <qmenubar.h>
+#include <qlayout.h>
#include <qworkspace.h>
#if defined(QT3_SUPPORT)
#include <q3popupmenu.h>
@@ -591,16 +592,25 @@ void tst_QWorkspace::childSize()
MyChild *child = new MyChild(&ws);
child->show();
+ ws.addWindow(child);
QCOMPARE(child->size(), child->sizeHint());
delete child;
child = new MyChild(&ws);
child->setFixedSize(200, 200);
child->show();
+ ws.addWindow(child);
QCOMPARE(child->size(), child->minimumSize());
+ QCOMPARE(child->parentWidget()->metaObject()->className(), "QWorkspaceChild");
+ QVERIFY(child->parentWidget()->width() >= 200);
+ // check that the minimum size is respected, using closestAcceptableSize
+ // like QSizeGrip does.
+ const QSize newSize = QLayout::closestAcceptableSize(child->parentWidget(), QSize(100, 100));
+ QVERIFY(newSize.width() >= 200);
delete child;
child = new MyChild(&ws);
+ ws.addWindow(child);
child->resize(150, 150);
child->show();
QCOMPARE(child->size(), QSize(150,150));