From 8e5578d3fcb86efad6bcde31a194ebd5009b1d70 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 10 Sep 2018 14:22:46 +0200 Subject: QQuickTableView: override fixup() to preserve contentX/Y at start-up Flickable::fixup() will be called from Flickable::componentComplete(). fixup() is a virtual function that subclasses can override to e.g ensure that cells snap to grid etc (which is not yet supported by TableView). The default implementation will check if the assigned contentX/Y is within the current content item size, and adjust it back to 0,0 if not. The problem is that during componentComplete(), the table has not yet been built. And we don't want Flickable to reset any assignments to contentX/Y until that has happened. So override the function and block it from doing any adjustments before the table has been built. Change-Id: Id6c5a3b5f053f71bf1854573cd5b9dc3ecc9f246 Reviewed-by: Mitch Curtis --- examples/quick/tableview/gameoflife/main.qml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/quick/tableview/gameoflife/main.qml b/examples/quick/tableview/gameoflife/main.qml index bf8c1151fe..90be69b9c0 100644 --- a/examples/quick/tableview/gameoflife/main.qml +++ b/examples/quick/tableview/gameoflife/main.qml @@ -97,11 +97,8 @@ ApplicationWindow { //! [model] //! [scroll] - Component.onCompleted: { - tableView.forceLayout() - tableView.contentX = (tableView.contentWidth - tableView.width) / 2; - tableView.contentY = (tableView.contentHeight - tableView.height) / 2; - } + contentX: (contentWidth - width) / 2; + contentY: (contentHeight - height) / 2; //! [scroll] } -- cgit v1.2.3