【发布时间】:2018-10-18 14:53:47
【问题描述】:
我有一个简单的 QuickControls2 QML 设计,其中图像应水平拉伸以填充应用程序窗口并保持其纵横比。但是当我运行我的程序时,图像不会缩放/拉伸。
是图片比当前窗口尺寸小,QT没有放大/增加图片尺寸的问题吗?是否有设置让 QT 调整图像大小以填充宽度而不考虑图像大小?
您能告诉我哪里出了问题以及如何解决吗?
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
ApplicationWindow {
id: applicationWindow
visible: true
width: 640
height: 480
title: qsTr("Scroll")
ColumnLayout {
id: mainLayout
anchors.fill: parent
Image {
id: imagePane
Layout.fillWidth: true
fillMode: Image.PreserveAspectFit
source: "placeholder.jpg"
}
}
}
【问题讨论】: