From 5b95cc34c15a021b0be37080b29f423144b5e64c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 10 Sep 2018 15:35:09 +0200 Subject: QQuickTableView: don't rebuild table upon querying content size Overriding contentWidth/Height was done to be able to force build the table early if the app needed to know the size of the table already at Component.onCompleted (to e.g center the viewport on the center of the table). But now that we have a forceLayout() function, it's better to require that that function should be called before querying contentWidth/Height at this stage. By not building the table on the fly, we allow the application to bind expressions directly to contentWidth/Height, without being concerned about potential binding loops that can occur as a result of us rebuilding the whole table behind his back. The benefit of this overshadows the need to call forceLayout() explicit for some corner cases. Note that we still redefine the contentWidth/Height properties in TableView so that we can catch if the application sets an explicit contentWidth/Height (which is tested by checkExplicitContentWidthAndHeight()). Change-Id: Ic4499b3939af1cb3a543e4c006023d0d6f12fd3b Reviewed-by: Mitch Curtis --- examples/quick/tableview/gameoflife/main.qml | 1 + 1 file changed, 1 insertion(+) (limited to 'examples') diff --git a/examples/quick/tableview/gameoflife/main.qml b/examples/quick/tableview/gameoflife/main.qml index 7ac26c477c..bf8c1151fe 100644 --- a/examples/quick/tableview/gameoflife/main.qml +++ b/examples/quick/tableview/gameoflife/main.qml @@ -98,6 +98,7 @@ ApplicationWindow { //! [scroll] Component.onCompleted: { + tableView.forceLayout() tableView.contentX = (tableView.contentWidth - tableView.width) / 2; tableView.contentY = (tableView.contentHeight - tableView.height) / 2; } -- cgit v1.2.3