[PATCH] QML UI: Don't explicitly set width of GridLayout items
Rick Walsh
rickmwalsh at gmail.com
Tue Jan 19 11:44:08 PST 2016
It is not recommended to set the width explicitly of items in a layout. This
caused some issues in DiveDetailsView, which were fixed by commit 1030cb2.
See http://doc.qt.io/qt-5/qml-qtquick-layouts-layout.html#details
Set 'Layout.preferredWidth' instead of 'width' for GpsList and Preferences
Signed-off-by: Rick Walsh <rickmwalsh at gmail.com>
---
I'm not aware that setting the width in GpsList or Preferences has caused issues, but it seemed like something worth addressing anyway
qt-mobile/qml/GpsList.qml | 4 ++--
qt-mobile/qml/Preferences.qml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/qt-mobile/qml/GpsList.qml b/qt-mobile/qml/GpsList.qml
index 8e9349c..422775e 100644
--- a/qt-mobile/qml/GpsList.qml
+++ b/qt-mobile/qml/GpsList.qml
@@ -53,7 +53,7 @@ MobileComponents.Page {
}
MobileComponents.Label {
text: date
- width: Math.max(parent.width / 5, paintedWidth) // helps vertical alignment throughout listview
+ Layout.preferredWidth: Math.max(parent.width / 5, paintedWidth)
font.pointSize: subsurfaceTheme.smallPointSize
}
MobileComponents.Label {
@@ -63,7 +63,7 @@ MobileComponents.Page {
}
MobileComponents.Label {
text: name
- width: Math.max(parent.width / 5, paintedWidth) // helps vertical alignment throughout listview
+ Layout.preferredWidth: Math.max(parent.width / 5, paintedWidth)
font.pointSize: subsurfaceTheme.smallPointSize
}
MobileComponents.Label {
diff --git a/qt-mobile/qml/Preferences.qml b/qt-mobile/qml/Preferences.qml
index 8ce739e..1644b59 100644
--- a/qt-mobile/qml/Preferences.qml
+++ b/qt-mobile/qml/Preferences.qml
@@ -57,7 +57,7 @@ GridLayout {
Item { width: MobileComponents.Units.gridUnit; height: width }
Item {
height: saveButton.height
- width: saveButton.width
+ Layout.preferredWidth: saveButton.width
Button {
id: saveButton
text: "Save"
--
2.5.0
More information about the subsurface
mailing list