summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-10 15:35:09 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-11 12:37:29 +0000
commit5b95cc34c15a021b0be37080b29f423144b5e64c (patch)
tree80748cfdff3a0e089cf884b9cea554edd25398c8 /examples
parentf3daa8bb97bbfc7a309c2bf59de1e41d279e05d1 (diff)
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 <mitch.curtis@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/tableview/gameoflife/main.qml1
1 files changed, 1 insertions, 0 deletions
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;
}