summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2014-03-03 14:42:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-19 18:18:16 +0100
commit89f9aa0038b76a5e06cf2621bd588ce89f2c7189 (patch)
tree0e648878d070e1a053232be617a634409afc87a8
parentf9bff211ba4efbae35b8dc4d764e2992a8132826 (diff)
downloadqtquickcontrols-89f9aa0038b76a5e06cf2621bd588ce89f2c7189.tar.gz
Let ApplicationWindows default max size be unbounded.
Previously, the ApplicationWindow determined its maximum size from its content items maximum size. This was inconsistent with how QWidgets normally behaved. The default max size of an ApplicationWindow is now therefore unbounded. If the application want the ApplicationWindow to have a maximum width or height, the application must set up the binding manually. This can be done with a fixed maximum size or it can be bound to a layout: contentItem.maximumHeight: grid.Layout.maximumHeight contentItem.maximumWidth: grid.Layout.maximumWidth If the grid layout has anchors.margins, those need to be taken into consideration too, resulting in the following binding: contentItem.maximumHeight: grid.Layout.maximumHeight + grid.anchors.topMargin + grid.anchors.bottomMargin Change-Id: Ibac80ba71f12e3eb9e5db8f875ecfa64b1e28b0d Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r--src/controls/Private/ContentItem.qml4
-rw-r--r--tests/auto/controls/data/tst_applicationwindow.qml35
2 files changed, 34 insertions, 5 deletions
diff --git a/src/controls/Private/ContentItem.qml b/src/controls/Private/ContentItem.qml
index dbb4a50e..edfd309d 100644
--- a/src/controls/Private/ContentItem.qml
+++ b/src/controls/Private/ContentItem.qml
@@ -45,8 +45,8 @@ Item {
id: contentItem
property real minimumWidth: __calcMinimum('Width')
property real minimumHeight: __calcMinimum('Height')
- property real maximumWidth: __calcMaximum('Width')
- property real maximumHeight: __calcMaximum('Height')
+ property real maximumWidth: Number.POSITIVE_INFINITY
+ property real maximumHeight: Number.POSITIVE_INFINITY
implicitWidth: __calcImplicitWidth()
implicitHeight: __calcImplicitHeight()
diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml
index 8e35caff..7450c705 100644
--- a/tests/auto/controls/data/tst_applicationwindow.qml
+++ b/tests/auto/controls/data/tst_applicationwindow.qml
@@ -122,13 +122,13 @@ TestCase {
expected: {implicitHeight: 0} },
{ tag: "minimum_implicit_maximum_anchorsFill",
input: {anchorsFill: true, Layout_minimumHeight: 10, implicitHeight: 100, Layout_maximumHeight: 150},
- expected: {minimumHeight: 10, implicitHeight: 100, maximumHeight: 150} },
+ expected: {minimumHeight: 10, implicitHeight: 100, maximumHeight: Number.POSITIVE_INFINITY} },
{ tag: "minimum_implicit_maximum_anchorsFill_margins",
input: {anchorsFill: true, anchors_margins: 20, Layout_minimumHeight: 10, implicitHeight: 100, Layout_maximumHeight: 150},
- expected: {minimumHeight: 50, implicitHeight: 140, maximumHeight: 190} },
+ expected: {minimumHeight: 50, implicitHeight: 140, maximumHeight: Number.POSITIVE_INFINITY} },
{ tag: "minimum_height_maximum_anchorsFill",
input: {anchorsFill: true, Layout_minimumHeight: 0, height: 100, Layout_maximumHeight: 150},
- expected: {minimumHeight: 0, implicitHeight: 0, maximumHeight: 150} },
+ expected: {minimumHeight: 0, implicitHeight: 0, maximumHeight: Number.POSITIVE_INFINITY} },
];
}
function test_defaultContentItemConstraints(data) {
@@ -206,5 +206,34 @@ TestCase {
window.destroy()
}
+ function test_defaultSizeHints() {
+ var test_control = 'import QtQuick 2.1; \
+ import QtQuick.Controls 1.1; \
+ import QtQuick.Layouts 1.1; \
+ ApplicationWindow { \
+ Rectangle { \
+ anchors.fill: parent; \
+ Layout.minimumWidth: 250; \
+ Layout.minimumHeight: 250; \
+ implicitWidth: 300; \
+ implicitHeight: 300; \
+ Layout.maximumWidth: 350; \
+ Layout.maximumHeight: 350; \
+ } \
+ } '
+
+ var window = Qt.createQmlObject(test_control, container, '')
+ window.visible = true
+ waitForRendering(window.contentItem)
+ compare(window.minimumWidth, 250)
+ compare(window.minimumHeight, 250)
+ compare(window.width, 300)
+ compare(window.height, 300)
+ var maxLimit = Math.pow(2,24)-1
+ compare(window.maximumWidth, maxLimit)
+ compare(window.maximumHeight, maxLimit)
+ window.destroy()
+ }
+
}
}