大家好! :)在Qt中將SVG圖像的畫布大小降低爲實際繪製的大小快速
我正在開發一個Qt快速控制2應用程序,我需要縮小一個SVG圖像是一個ColumnLayout的一部分,以適應屏幕高度。這裏是我的代碼:
Page {
title: "About"
ColumnLayout {
anchors.fill: parent
spacing: 20
Image {
id: app_logo
source: "images/app_logo.svg"
mipmap: true
Layout.maximumWidth: Math.min(parent.width, 300)
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
verticalAlignment: Qt.AlignTop
fillMode: Image.PreserveAspectFit
}
Label {
text: "Version 0.1"
font.pointSize: 15
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
}
}
}
原來SVG大小1200x500,所得塗圖像300x125,這也是由paintedWidth和paintedHeight屬性顯示。我所面臨的問題是,SVG的畫布上沒有變化,其餘1200x500,其移動其他控件(如標籤)從屏幕:
如何設置畫布大小實際畫大小不會導致綁定循環?
謝謝,此代碼有效;然而,仍然有一個警告:'qrc:/main.qml:20:5:QML頁面:檢測到屬性「contentHeight」的綁定循環' – Ilya