0
我有一个嵌套RowLayout
的QML窗口。在内排我有两个图像。这些图像的源文件(有意)是相当大的。当我试图设置这些图像上的height
属性以使它们变小时,它们仍然很大。调整QML图像显示大小
我已经能够让他们小的唯一方法是设置sourceSize.height:100
而不是height:100
;然而,这不是我想要的。我希望他们能够在不重新加载的情况下进行缩放。
我该如何修复我的QML,以便图像具有包含RowLayout
的高度?
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
width:600; height:300
visible:true
Rectangle {
color:'red'
anchors { top:header.bottom; bottom:footer.top; left:parent.left; right:parent.right }
}
header:RowLayout {
id:header
spacing:0
height:100; width:parent.width
RowLayout {
id:playcontrol
Layout.minimumWidth:200; Layout.maximumWidth:200; Layout.preferredWidth:200
height:parent.height
Image {
// I really want these to take on the height of their row
source:'qrc:/img/play.png'
width:100; height:100
fillMode:Image.PreserveAspectFit; clip:true
}
Image {
source:'qrc:/img/skip.png'
width:100; height:100
fillMode:Image.PreserveAspectFit; clip:true
}
}
Rectangle {
color:'#80CC00CC'
Layout.minimumWidth:200
Layout.preferredWidth:parent.width*0.7
Layout.fillWidth:true; Layout.fillHeight:true
height:parent.height
}
}
footer:Rectangle { height:100; color:'blue' }
}