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.
This commit is contained in:
Ghostkeeper 2022-02-01 13:04:16 +01:00
parent 8de1f923a4
commit 02c517a841
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
2 changed files with 2 additions and 2 deletions

View file

@ -90,7 +90,7 @@ Item
new_width -= sum_widths - tableBase.width; //Limit the total width to not exceed the view. 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. 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)) });
} }
} }
} }

View file

@ -91,7 +91,7 @@ Item
new_width -= sum_widths - tableBase.width; //Limit the total width to not exceed the view. 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. 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)) });
} }
} }
} }