From f51d9f960b0287de2c18157e56c88ce53357d74b Mon Sep 17 00:00:00 2001 From: Mentalflow <312902918@qq.com> Date: Sun, 30 Apr 2023 13:50:51 +0800 Subject: [PATCH] Allow the table to set the maximum height of each row based on the content. --- src/imports/FluentUI/Controls/FluTableView.qml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/imports/FluentUI/Controls/FluTableView.qml b/src/imports/FluentUI/Controls/FluTableView.qml index c2d6e7ab..595adb76 100644 --- a/src/imports/FluentUI/Controls/FluTableView.qml +++ b/src/imports/FluentUI/Controls/FluTableView.qml @@ -57,6 +57,7 @@ Item { width: model.width FluText{ text:model.title + wrapMode: Text.WordWrap anchors{ verticalCenter: parent.verticalCenter left: parent.left @@ -111,18 +112,20 @@ Item { } model:model_data_source delegate: Item{ - height: list_coumns.height + height: table_row.maxHeight width: layout_table.width property var model_values : getObjectValues(index) property var itemObject: getObject(index) property var listModel: model Row{ + id: table_row spacing: 0 anchors.fill: parent + property int maxHeight: itemHeight Repeater{ model: model_values delegate:Item{ - height: list_coumns.height + height: table_row.maxHeight width: modelData.width Loader{ property var model : modelData @@ -135,6 +138,12 @@ Item { } return com_text } + onHeightChanged: + { + table_row.maxHeight = Math.max(table_row.maxHeight,height,itemHeight) + parent.height = table_row.maxHeight + table_row.parent.height = table_row.maxHeight + } } } } @@ -157,9 +166,11 @@ Item { anchors.fill: parent } FluText{ + id:table_value text:String(model.itemData) width: parent.width - 14 - elide: Text.ElideRight + wrapMode: Text.WordWrap + onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight) anchors{ verticalCenter: parent.verticalCenter left: parent.left