【发布时间】:2017-12-12 13:41:48
【问题描述】:
场景:
我在 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
}
}
}
问题:
如何设置my_image_view_container 的width 和height 以便将my_image 完全放入my_image_view_container 而不影响其纵横比?
【问题讨论】:
标签: image qt qml qtquick2 qimage