QML: how to specify image file path relative to application folder

前端 未结 3 1010
天命终不由人
天命终不由人 2020-12-10 03:00

We are developing our first Qt/QML application (trying technology). While technology looks very promising at a glance, we have faced so many unexpected weird issues that alm

3条回答
  •  庸人自扰
    2020-12-10 03:35

    Image {
       source: "file:resources/images/image.png"
    }
    

    will work if the working directory is set to the ApplicationFolder

    note: when running from QtCreator, double check what directory the application is actually running in (i had my application run in my home directory even though the working directory was set correctly in the run configuration (after running it once in a terminal window this magically fixed itself) )

提交回复
热议问题