From b5a6b4c938660d0cd6eae8a8b36b43b1795d584d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 18 Nov 2019 15:47:01 +0100 Subject: [PATCH] Avoid access to properties of parent in imagelements example ImageCell's parent is not guaranteed to have these properties. Therefore, rather pass them from the outside. Change-Id: Ib42d1b9087d8757633b14c3a25cb638abb70fb21 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- .../quick/imageelements/content/ImageCell.qml | 2 -- examples/quick/imageelements/image.qml | 34 +++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/examples/quick/imageelements/content/ImageCell.qml b/examples/quick/imageelements/content/ImageCell.qml index 4b147633c3..7804346bd4 100644 --- a/examples/quick/imageelements/content/ImageCell.qml +++ b/examples/quick/imageelements/content/ImageCell.qml @@ -53,8 +53,6 @@ Item { property alias mode: image.fillMode property alias caption: captionItem.text - width: parent.cellWidth; height: parent.cellHeight - Image { id: image width: parent.width; height: parent.height - captionItem.height diff --git a/examples/quick/imageelements/image.qml b/examples/quick/imageelements/image.qml index d414f59629..0750ea3b79 100644 --- a/examples/quick/imageelements/image.qml +++ b/examples/quick/imageelements/image.qml @@ -65,12 +65,34 @@ Rectangle { rows: 3 spacing: 30 - ImageCell { mode: Image.Stretch; caption: "Stretch" } - ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } - ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } + component SizedImageCell: ImageCell { + width: parent.cellWidth + height: parent.cellHeight + } - ImageCell { mode: Image.Tile; caption: "Tile" } - ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } - ImageCell { mode: Image.TileVertically; caption: "TileVertically" } + SizedImageCell { + mode: Image.Stretch + caption: "Stretch" + } + SizedImageCell { + mode: Image.PreserveAspectFit + caption: "PreserveAspectFit" + } + SizedImageCell { + mode: Image.PreserveAspectCrop + caption: "PreserveAspectCrop" + } + SizedImageCell { + mode: Image.Tile + caption: "Tile" + } + SizedImageCell { + mode: Image.TileHorizontally + caption: "TileHorizontally" + } + SizedImageCell { + mode: Image.TileVertically + caption: "TileVertically" + } } }