Gam*_*ads 1 qt image qimage qml qtquick2
场景:
我在QML中有一个Image组件,其中包含一个纵横比不同的QImage。
码:
Window {
id: app_window
visible: true
Rectangle {
id: my_image_view_container
width: app_window.width
height: app_window.height
Image {
id: my_image
// changes at runtime based on the image my app selects
source: "random/path/to/an/image.jpg"
width: sourceSize.width
height: sourceSize.height
scale: Qt.KeepAspectRatio
}
}
}
Run Code Online (Sandbox Code Playgroud)
问:
我如何设定width及height的my_image_view_container,以适应my_image完全内my_image_view_container不影响到其长宽比?