on xenial help sign in
Different way of top aligning labels when the other one in the row is multiline
fadec19Albert Astals Cid
qml/Dash/Previews/PreviewTable.qml+2−3
@@ -74,9 +74,8 @@ PreviewWidget {
74 visible: root.expanded || rowIndex < maximumCollapsedRowCount
74 visible: root.expanded || rowIndex < maximumCollapsedRowCount
75 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
75 color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
76 font.bold: index == 0
76 font.bold: index == 0
77− verticalAlignment: Text.AlignTop
78− wrapMode: Text.WordWrap
77+ wrapMode: Text.Wrap
79− Layout.fillHeight: true
78+ Layout.alignment: Qt.AlignTop
80 Layout.maximumWidth: column.width - x
79 Layout.maximumWidth: column.width - x
81 }
80 }
82 }
81 }
tests/qmltests/Dash/Previews/tst_PreviewTable.qml+15−4
@@ -28,24 +28,27 @@ Rectangle {
28
28
29 property var widgetDataComplete: {
29 property var widgetDataComplete: {
30 "title": "Title here longa long long long long long long long long long long",
30 "title": "Title here longa long long long long long long long long long long",
31− "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
31+ "values": [ [ "Long Label 1", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
32 }
32 }
33
33
34 property var widgetDataNoTitle: {
34 property var widgetDataNoTitle: {
35− "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
35+ "values": [ [ "Long Label 1", "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 2", "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
36 }
36 }
37
37
38 PreviewWidgetFactory {
38 PreviewWidgetFactory {
39 id: previewTable
39 id: previewTable
40 anchors { left: parent.left; right: parent.right }
40 anchors { left: parent.left; right: parent.right }
41 widgetType: "table"
41 widgetType: "table"
42− widgetData: widgetDataComplete
43
42
44 Rectangle {
43 Rectangle {
45 color: "red"
44 color: "red"
46 anchors.fill: parent
45 anchors.fill: parent
47 opacity: 0.5
46 opacity: 0.5
48 }
47 }
48+
49+ Component.onCompleted: {
50+ previewTable.widgetData = widgetDataComplete
51+ }
49 }
52 }
50
53
51 UT.UnityTestCase {
54 UT.UnityTestCase {
@@ -56,9 +59,17 @@ Rectangle {
56 previewTable.widgetData = widgetDataComplete;
59 previewTable.widgetData = widgetDataComplete;
57 }
60 }
58
61
62+ function test_label_heights() {
63+ verify(findChild(previewTable, "label00").height == findChild(previewTable, "label10").height);
64+ verify(findChild(previewTable, "label01").height == findChild(previewTable, "label11").height);
65+ verify(findChild(previewTable, "label01").height > findChild(previewTable, "label00").height * 3);
66+ verify(findChild(previewTable, "label00").height == findChild(previewTable, "label20").height);
67+ verify(findChild(previewTable, "label20").height == findChild(previewTable, "label21").height);
68+ }
69+
59 function test_values() {
70 function test_values() {
60 compare(findChild(previewTable, "label00").text, "Long Label 1");
71 compare(findChild(previewTable, "label00").text, "Long Label 1");
61− compare(findChild(previewTable, "label01").text, "Value 1");
72+ compare(findChild(previewTable, "label01").text, "Long Value 1 Long Value 2 Long Value 3 Long Value 4 Long Value 5 Long Value 6 Long Value 2 Long Value 2 Long Value 2 Long Value 2");
62 compare(findChild(previewTable, "label10").text, "Label 2");
73 compare(findChild(previewTable, "label10").text, "Label 2");
63 compare(findChild(previewTable, "label11").text, "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2");
74 compare(findChild(previewTable, "label11").text, "Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2 Long Value 2");
64 compare(findChild(previewTable, "label20").text, "Label 3");
75 compare(findChild(previewTable, "label20").text, "Label 3");