From fe2543ab4d6f1790ae9a69ce5da79600aa2b2cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Sun, 5 May 2024 22:03:41 +0800 Subject: [PATCH] fix bug --- .../FluentUI/Controls/FluTableView.qml | 5 ++++ .../imports/FluentUI/Controls/FluTreeView.qml | 3 +++ .../FluentUI/Controls/FluTableView.qml | 5 ++++ .../imports/FluentUI/Controls/FluTreeView.qml | 25 +++++++++++-------- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml index 1796723e..14d6868c 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml @@ -19,6 +19,7 @@ Rectangle { property bool verticalHeaderVisible: true property color selectedBorderColor: FluTheme.primaryColor property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3) + property alias view: table_view id:control color: { if(Window.active){ @@ -47,6 +48,9 @@ Rectangle { header_column_model.rows = [headerRow] } } + Component.onDestruction: { + table_view.contentY = 0 + } QtObject{ id:d property var current @@ -896,6 +900,7 @@ Rectangle { item_table_frozen_header.contentX = columnModel.width * _index item_table_frozen.contentX = columnModel.width * _index } + } } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluTreeView.qml b/src/Qt5/imports/FluentUI/Controls/FluTreeView.qml index df84c4d5..619bbb29 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTreeView.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTreeView.qml @@ -45,6 +45,9 @@ Rectangle { id:tree_model columnSource: control.columnSource } + Component.onDestruction: { + table_view.contentY = 0 + } onDepthPaddingChanged: { table_view.forceLayout() } diff --git a/src/Qt6/imports/FluentUI/Controls/FluTableView.qml b/src/Qt6/imports/FluentUI/Controls/FluTableView.qml index bd592d44..9f9b34a1 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTableView.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTableView.qml @@ -19,6 +19,7 @@ Rectangle { property bool verticalHeaderVisible: true property color selectedBorderColor: FluTheme.primaryColor property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3) + property alias view: table_view id:control color: { if(Window.active){ @@ -47,6 +48,9 @@ Rectangle { header_column_model.rows = [headerRow] } } + Component.onDestruction: { + table_view.contentY = 0 + } QtObject{ id:d property var current @@ -896,6 +900,7 @@ Rectangle { item_table_frozen_header.contentX = columnModel.width * _index item_table_frozen.contentX = columnModel.width * _index } + } } } diff --git a/src/Qt6/imports/FluentUI/Controls/FluTreeView.qml b/src/Qt6/imports/FluentUI/Controls/FluTreeView.qml index 432f1b74..8dc1e95d 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTreeView.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTreeView.qml @@ -28,21 +28,26 @@ Rectangle { tree_model.setDataSource(dataSource) } onColumnSourceChanged: { - var columns= [] - var headerRow = {} - columnSource.forEach(function(item){ - var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',control); - column.display = item.dataIndex - columns.push(column) - headerRow[item.dataIndex] = item.title - }) - header_column_model.columns = columns - header_column_model.rows = [headerRow] + if(columnSource.length !== 0){ + var columns= [] + var headerRow = {} + columnSource.forEach(function(item){ + var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',control); + column.display = item.dataIndex + columns.push(column) + headerRow[item.dataIndex] = item.title + }) + header_column_model.columns = columns + header_column_model.rows = [headerRow] + } } FluTreeModel{ id:tree_model columnSource: control.columnSource } + Component.onDestruction: { + table_view.contentY = 0 + } onDepthPaddingChanged: { table_view.forceLayout() }