Qt快速图像不显示

Qt Quick image not showing

本文关键字:显示 图像 Qt      更新时间:2023-10-16

当我尝试将图像添加到新qt快速项目的模板时,它会编译并显示窗口,但仅显示编辑文本和矩形。

import QtQuick 2.6
Rectangle {
property alias mouseArea: mouseArea
property alias textEdit: textEdit
width: 360
height: 360
MouseArea {
id: mouseArea
anchors.fill: parent
}
TextEdit {
id: textEdit
text: qsTr("Enter some text...")
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
Rectangle {
anchors.fill: parent
anchors.margins: -10
color: "transparent"
border.width: 1
}
}
Image {
id: image
x: 207
y: 235
width: 100
height: 100
source: "../../QtIcon.png"
}

}

您可以通过添加 infront file://在文件系统中使用图像。 示例:来源:"file://C:/test.png">