From 02c517a841b90264dc232c369b53ea0500fede32 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 1 Feb 2022 13:04:16 +0100 Subject: [PATCH] Enforce minimum column width through binding formula We can't enforce it when resizing, due to the width rescaling with the width. But we can enforce it through the binding formula after applying the width scale. Contributes to issue CURA-8686. --- plugins/DigitalLibrary/resources/qml/Table.qml | 2 +- resources/qml/TableView.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/DigitalLibrary/resources/qml/Table.qml b/plugins/DigitalLibrary/resources/qml/Table.qml index b503bb8e2f..0f539675a0 100644 --- a/plugins/DigitalLibrary/resources/qml/Table.qml +++ b/plugins/DigitalLibrary/resources/qml/Table.qml @@ -90,7 +90,7 @@ Item new_width -= sum_widths - tableBase.width; //Limit the total width to not exceed the view. } let width_fraction = new_width / tableBase.width; //Scale with the same fraction along with the total width, if the table is resized. - parent.parent.width = Qt.binding(function() { return tableBase.width * width_fraction }); + parent.parent.width = Qt.binding(function() { return Math.max(10, Math.round(tableBase.width * width_fraction)) }); } } } diff --git a/resources/qml/TableView.qml b/resources/qml/TableView.qml index 1fedc34ca0..1075ce1f8a 100644 --- a/resources/qml/TableView.qml +++ b/resources/qml/TableView.qml @@ -91,7 +91,7 @@ Item new_width -= sum_widths - tableBase.width; //Limit the total width to not exceed the view. } let width_fraction = new_width / tableBase.width; //Scale with the same fraction along with the total width, if the table is resized. - parent.parent.width = Qt.binding(function() { return tableBase.width * width_fraction }); + parent.parent.width = Qt.binding(function() { return Math.max(10, Math.round(tableBase.width * width_fraction)) }); } } }