From 9aa95dc233d91bf2f10ea1cf79dec0ff13379c2d Mon Sep 17 00:00:00 2001 From: Rick Walsh Date: Wed, 4 May 2016 07:30:55 +1000 Subject: QML Set width instead of minimumWidth equal to maximumWidth The QML manual advises against setting width property of gridLayout children directly, and recommends setting preferred, min and/or max width instead, letting QML do the work to determine the optimum width. But we've found letting QML determine gridLayout widths leads to infinite loops in too many situations, so we're forcing a width. It's better to force a width by setting it directly, rather than setting minimum = maximum. Signed-off-by: Rick Walsh Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveDetailsView.qml | 36 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/mobile-widgets/qml/DiveDetailsView.qml b/mobile-widgets/qml/DiveDetailsView.qml index 6a4dd902e..6a514acea 100644 --- a/mobile-widgets/qml/DiveDetailsView.qml +++ b/mobile-widgets/qml/DiveDetailsView.qml @@ -144,8 +144,7 @@ Item { text: qsTr("Suit:") wrapMode: Text.WrapAtWordBoundaryOrAnywhere opacity: 0.6 - Layout.maximumWidth: detailsView.col1Width - Layout.minimumWidth: detailsView.col1Width + width: detailsView.col1Width Layout.alignment: Qt.AlignRight } Kirigami.Label { @@ -159,23 +158,20 @@ Item { text: qsTr("Air Temp:") wrapMode: Text.WrapAtWordBoundaryOrAnywhere opacity: 0.6 - Layout.maximumWidth: detailsView.col3Width - Layout.minimumWidth: detailsView.col3Width + width: detailsView.col3Width Layout.alignment: Qt.AlignRight } Kirigami.Label { id: txtAirTemp text: dive.airTemp wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - Layout.maximumWidth: detailsView.col4Width - Layout.minimumWidth: detailsView.col4Width + width: detailsView.col4Width } Kirigami.Label { text: qsTr("Cylinder:") opacity: 0.6 - Layout.maximumWidth: detailsView.col1Width - Layout.minimumWidth: detailsView.col1Width + width: detailsView.col1Width Layout.alignment: Qt.AlignRight } Kirigami.Label { @@ -189,24 +185,21 @@ Item { text: qsTr("Water Temp:") wrapMode: Text.WrapAtWordBoundaryOrAnywhere opacity: 0.6 - Layout.maximumWidth: detailsView.col3Width - Layout.minimumWidth: detailsView.col3Width + width: detailsView.col3Width Layout.alignment: Qt.AlignRight } Kirigami.Label { id: txtWaterTemp text: dive.waterTemp wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - Layout.maximumWidth: detailsView.col4Width - Layout.minimumWidth: detailsView.col4Width + width: detailsView.col4Width } Kirigami.Label { text: qsTr("Dive Master:") wrapMode: Text.WrapAtWordBoundaryOrAnywhere opacity: 0.6 - Layout.maximumWidth: detailsView.col1Width - Layout.minimumWidth: detailsView.col1Width + width: detailsView.col1Width Layout.alignment: Qt.AlignRight } Kirigami.Label { @@ -219,16 +212,14 @@ Item { Kirigami.Label { text: qsTr("Weight:") opacity: 0.6 - Layout.maximumWidth: detailsView.col3Width - Layout.minimumWidth: detailsView.col3Width + width: detailsView.col3Width Layout.alignment: Qt.AlignRight } Kirigami.Label { id: txtWeight text: dive.sumWeight wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - Layout.maximumWidth: detailsView.col4Width - Layout.minimumWidth: detailsView.col4Width + width: detailsView.col4Width } } // clearly, Qt 5.6.0 is buggy as having this as one GridLayout @@ -248,8 +239,7 @@ Item { Kirigami.Label { text: qsTr("Buddy:") opacity: 0.6 - Layout.maximumWidth: detailsView.col1Width - Layout.minimumWidth: detailsView.col1Width + width: detailsView.col1Width Layout.alignment: Qt.AlignRight } Kirigami.Label { @@ -262,16 +252,14 @@ Item { Kirigami.Label { text: qsTr("SAC:") opacity: 0.6 - Layout.maximumWidth: detailsView.col3Width - Layout.minimumWidth: detailsView.col3Width + width: detailsView.col3Width Layout.alignment: Qt.AlignRight } Kirigami.Label { id: txtSAC text: dive.sac wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - Layout.maximumWidth: detailsView.col4Width - Layout.minimumWidth: detailsView.col4Width + width: detailsView.col4Width } Kirigami.Heading { -- cgit v1.2.3-70-g09d2