summaryrefslogtreecommitdiff
path: root/src/controls
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2018-10-19 11:51:39 +0200
committerAndy Shaw <andy.shaw@qt.io>2018-11-16 14:56:10 +0000
commit10b3bffbd21b6265a3d124f310c99fcbac2b027f (patch)
treeef03abcffacf76646ab5bfd933cadbe644b685e9 /src/controls
parent602f1225938f9338c3ee799c64d5449ebc12b8bc (diff)
downloadqtquickcontrols-10b3bffbd21b6265a3d124f310c99fcbac2b027f.tar.gz
TableView: Handle dynamic insertion of TableViewColumns correctly
When inserting a TableViewColumn after the TableView is created, then it needs to be inserted into the list of columns at the specified index so that it responds correctly to things like resizeColumnsToContents() Fixes: QTBUG-58594 Change-Id: If7ff545306fe8b6616d8e016eb87e565ed40c836 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/Private/BasicTableView.qml11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/controls/Private/BasicTableView.qml b/src/controls/Private/BasicTableView.qml
index 2557dca7..1f846b57 100644
--- a/src/controls/Private/BasicTableView.qml
+++ b/src/controls/Private/BasicTableView.qml
@@ -260,6 +260,17 @@ ScrollView {
if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) {
object.__view = root
columnModel.insert(index, {columnItem: object})
+ if (root.__columns[index] !== object) {
+ // The new column needs to be put into __columns at the specified index
+ // so the list needs to be recreated to be correct
+ var arr = []
+ for (var i = 0; i < index; ++i)
+ arr.push(root.__columns[i])
+ arr.push(object)
+ for (i = index; i < root.__columns.length; ++i)
+ arr.push(root.__columns[i])
+ root.__columns = arr
+ }
return object
}