unable to use images in QML
-
hi, i was attempting to learn to use images, but this simple code simply doesnt work for me, even tho i can see it in design studio. i get the following error
qrc:/wtf/Main.qml:11:5: QML Image: Cannot open: qrc:/wtf/myimage.png15:2import QtQuick import QtQuick.Window Window { width: 640 height: 480 opacity: 0.6 visible: true title: qsTr("Hello World") Image { id: image x: 270 y: 139 width: 100 height: 100 opacity: 1 source: "myimage.png" fillMode: Image.PreserveAspectFit } }
i also have a resource file ,which contains the png image with the same name as in the source declaration...
any insights on what i could be doing wrong here?
-
hi, i was attempting to learn to use images, but this simple code simply doesnt work for me, even tho i can see it in design studio. i get the following error
qrc:/wtf/Main.qml:11:5: QML Image: Cannot open: qrc:/wtf/myimage.png15:2import QtQuick import QtQuick.Window Window { width: 640 height: 480 opacity: 0.6 visible: true title: qsTr("Hello World") Image { id: image x: 270 y: 139 width: 100 height: 100 opacity: 1 source: "myimage.png" fillMode: Image.PreserveAspectFit } }
i also have a resource file ,which contains the png image with the same name as in the source declaration...
any insights on what i could be doing wrong here?
-
@wiadro that is not the source code that produces the error message. because this :
source: "myimage.png"
is a relative path and does not refer to a resource file, like the error message says. -
@J-Hilk what do i need to do, there is no other code besides main.qml which is in its default state.