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 <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Rick Walsh 2016-05-04 07:30:55 +10:00 committed by Dirk Hohndel
parent d8699110d3
commit 9aa95dc233

View file

@ -144,8 +144,7 @@ Item {
text: qsTr("Suit:") text: qsTr("Suit:")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col1Width width: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
@ -159,23 +158,20 @@ Item {
text: qsTr("Air Temp:") text: qsTr("Air Temp:")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col3Width width: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
id: txtAirTemp id: txtAirTemp
text: dive.airTemp text: dive.airTemp
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width width: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
} }
Kirigami.Label { Kirigami.Label {
text: qsTr("Cylinder:") text: qsTr("Cylinder:")
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col1Width width: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
@ -189,24 +185,21 @@ Item {
text: qsTr("Water Temp:") text: qsTr("Water Temp:")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col3Width width: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
id: txtWaterTemp id: txtWaterTemp
text: dive.waterTemp text: dive.waterTemp
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width width: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
} }
Kirigami.Label { Kirigami.Label {
text: qsTr("Dive Master:") text: qsTr("Dive Master:")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col1Width width: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
@ -219,16 +212,14 @@ Item {
Kirigami.Label { Kirigami.Label {
text: qsTr("Weight:") text: qsTr("Weight:")
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col3Width width: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
id: txtWeight id: txtWeight
text: dive.sumWeight text: dive.sumWeight
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width width: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
} }
} }
// clearly, Qt 5.6.0 is buggy as having this as one GridLayout // clearly, Qt 5.6.0 is buggy as having this as one GridLayout
@ -248,8 +239,7 @@ Item {
Kirigami.Label { Kirigami.Label {
text: qsTr("Buddy:") text: qsTr("Buddy:")
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col1Width width: detailsView.col1Width
Layout.minimumWidth: detailsView.col1Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
@ -262,16 +252,14 @@ Item {
Kirigami.Label { Kirigami.Label {
text: qsTr("SAC:") text: qsTr("SAC:")
opacity: 0.6 opacity: 0.6
Layout.maximumWidth: detailsView.col3Width width: detailsView.col3Width
Layout.minimumWidth: detailsView.col3Width
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
Kirigami.Label { Kirigami.Label {
id: txtSAC id: txtSAC
text: dive.sac text: dive.sac
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
Layout.maximumWidth: detailsView.col4Width width: detailsView.col4Width
Layout.minimumWidth: detailsView.col4Width
} }
Kirigami.Heading { Kirigami.Heading {