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 <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Ulf Hermann 2019-11-18 15:47:01 +01:00
parent 461ecc535a
commit b5a6b4c938
2 changed files with 28 additions and 8 deletions

View File

@ -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

View File

@ -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"
}
}
}