QtQuick.TableView stretch columns to fit contents
-
What is the proper way to have a QtQuick.TableView stretch certain columns to fill the width of the table as with
QHeaderView::Stretch?contentWidth: widthseems to disable horizontal scrolling, but it won't stretch the table to fit the width.The documentation for
TableView.contentWidthProvidersays that returning negative number will have the column fall back on the delegate for column widths. This is incorrect, as the code prohibits and complains when a negative number is returned:QML TableView: columnWidthProvider did not return a valid width for column: 2But even if
TableView.contentWidthProviderdid work, it would not stretch the table to fill the full with. -
What is the proper way to have a QtQuick.TableView stretch certain columns to fill the width of the table as with
QHeaderView::Stretch?contentWidth: widthseems to disable horizontal scrolling, but it won't stretch the table to fit the width.The documentation for
TableView.contentWidthProvidersays that returning negative number will have the column fall back on the delegate for column widths. This is incorrect, as the code prohibits and complains when a negative number is returned:QML TableView: columnWidthProvider did not return a valid width for column: 2But even if
TableView.contentWidthProviderdid work, it would not stretch the table to fill the full with.@patrickkidd said in QtQuick.TableView stretch columns to fit contents:
What is the proper way to have a QtQuick.TableView stretch certain columns to fill the width of the table as with
QHeaderView::Stretch?contentWidth: widthseems to disable horizontal scrolling, but it won't stretch the table to fit the width.The documentation for
TableView.contentWidthProvidersays that returning negative number will have the column fall back on the delegate for column widths. This is incorrect, as the code prohibits and complains when a negative number is returned:QML TableView: columnWidthProvider did not return a valid width for column: 2But even if
TableView.contentWidthProviderdid work, it would not stretch the table to fill the full with.I managed to implement a column stretch by manually calculating each column width after every change to the TableView width, calling forceLayout() after every onWidthChanged. It looks like this is the only way to do this until the official table header type is added in a Qt update.
-
This post is deleted!