aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-12-05 12:35:08 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-12-09 16:27:00 +0000
commit10458b3d4dc1ed9f06eece9d61d2e699e602117d (patch)
treebdffb6b584965cbe8a03d4dffea2097201bddefe /src/imports/controls
parentf2f9786e6194725bf48ee3833b1fdf9603b74e69 (diff)
GroupBox: add an example of a checkable groupbox
Adjust the size calculation so that the example works smooth. Change-Id: Iaf25107b0cfaa3ceef0caeba120d1bd74c9bc854 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/GroupBox.qml6
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-groupbox-checkable.pngbin0 -> 8264 bytes
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-groupbox-checkable.qml48
-rw-r--r--src/imports/controls/material/GroupBox.qml6
-rw-r--r--src/imports/controls/universal/GroupBox.qml6
5 files changed, 60 insertions, 6 deletions
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index 8504fae9..08866606 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -40,7 +40,9 @@ import Qt.labs.templates 1.0 as T
T.GroupBox {
id: control
- implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ label ? label.implicitWidth + leftPadding + rightPadding : 0,
+ contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0
@@ -48,7 +50,7 @@ T.GroupBox {
spacing: 6
padding: 6
- topPadding: 6 + (label && title ? label.implicitHeight + spacing : 0)
+ topPadding: 6 + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0)
//! [contentItem]
contentItem: Item { }
diff --git a/src/imports/controls/doc/images/qtlabscontrols-groupbox-checkable.png b/src/imports/controls/doc/images/qtlabscontrols-groupbox-checkable.png
new file mode 100644
index 00000000..8b619b5b
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-groupbox-checkable.png
Binary files differ
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-checkable.qml b/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-checkable.qml
new file mode 100644
index 00000000..1c1232c7
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-checkable.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+import Qt.labs.controls 1.0
+
+//! [1]
+GroupBox {
+ label: CheckBox {
+ id: checkBox
+ checked: true
+ text: qsTr("Synchronize")
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ enabled: checkBox.checked
+ CheckBox { text: qsTr("E-mail") }
+ CheckBox { text: qsTr("Calendar") }
+ CheckBox { text: qsTr("Contacts") }
+ }
+}
+//! [1]
diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml
index de47ff14..cbdc585e 100644
--- a/src/imports/controls/material/GroupBox.qml
+++ b/src/imports/controls/material/GroupBox.qml
@@ -41,7 +41,9 @@ import Qt.labs.controls.material 1.0
T.GroupBox {
id: control
- implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ label ? label.implicitWidth + leftPadding + rightPadding : 0,
+ contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0
@@ -49,7 +51,7 @@ T.GroupBox {
spacing: 6
padding: 6
- topPadding: 6 + (label && title ? label.implicitHeight + spacing : 0)
+ topPadding: 6 + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0)
//! [contentItem]
contentItem: Item {}
diff --git a/src/imports/controls/universal/GroupBox.qml b/src/imports/controls/universal/GroupBox.qml
index cf7b7405..524203db 100644
--- a/src/imports/controls/universal/GroupBox.qml
+++ b/src/imports/controls/universal/GroupBox.qml
@@ -41,7 +41,9 @@ import Qt.labs.controls.universal 1.0
T.GroupBox {
id: control
- implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ label ? label.implicitWidth + leftPadding + rightPadding : 0,
+ contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0
@@ -49,7 +51,7 @@ T.GroupBox {
spacing: 12
padding: 12
- topPadding: 12 + (label && title ? label.implicitHeight + spacing : 0)
+ topPadding: 12 + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0)
//! [contentItem]
contentItem: Item { }