Relative Paths for Images
-
Hi everyone, I am quite new to Qt and I'm struggling a bit at the moment. I am using Qt Design Studio to build my application but also doing some light coding. I have managed to import my project into Qt Creator and build a working exe file. Now, I would like to have a folder right next to my exe where I keep my footage so that in case that I want to update said footage I can simply overwrite the file without having to rebuild. I was able to get this working with an absolute path but when I try using a relative path the images get embeded into the exe. This is an example of the paths that I am using:
ListModel {
id: pathModelListElement { source: "../footage/thumbnails/ducks_thumbnail.jpg" isVideo: true } ListElement { source: "../footage/thumbnails/tea_thumbnail.jpg" isVideo: true } ListElement { source: "../footage/thumbnails/ducks_thumbnail.jpg" isVideo: false } ListElement { source: "../footage/thumbnails/steam_thumbnail.jpg" isVideo: true } ListElement { source: "../footage/thumbnails/girl_talking_thumbnail.jpg" isVideo: true } }
Thanks in advance!
-
Hi everyone, I am quite new to Qt and I'm struggling a bit at the moment. I am using Qt Design Studio to build my application but also doing some light coding. I have managed to import my project into Qt Creator and build a working exe file. Now, I would like to have a folder right next to my exe where I keep my footage so that in case that I want to update said footage I can simply overwrite the file without having to rebuild. I was able to get this working with an absolute path but when I try using a relative path the images get embeded into the exe. This is an example of the paths that I am using:
ListModel {
id: pathModelListElement { source: "../footage/thumbnails/ducks_thumbnail.jpg" isVideo: true } ListElement { source: "../footage/thumbnails/tea_thumbnail.jpg" isVideo: true } ListElement { source: "../footage/thumbnails/ducks_thumbnail.jpg" isVideo: false } ListElement { source: "../footage/thumbnails/steam_thumbnail.jpg" isVideo: true } ListElement { source: "../footage/thumbnails/girl_talking_thumbnail.jpg" isVideo: true } }
Thanks in advance!
@danilo_jn said in Relative Paths for Images:
but when I try using a relative path the images get embeded into the exe
I don't get it: how should this happen? Or do you use a resource file?
-
@danilo_jn said in Relative Paths for Images:
but when I try using a relative path the images get embeded into the exe
I don't get it: how should this happen? Or do you use a resource file?
@jsulm So as far as I can tell a resource file is automatically generated either when I export the CMake build files or when I open the CMakeLists file in Qt Creator. I did not write one myself. This is how it looks:
<RCC>
<qresource prefix="/qt/qml/content/">
<file alias="App.qml">C:/QtProjects/Meiningen_Gesellschaft/content/App.qml</file>
<file alias="Screen01.ui.qml">C:/QtProjects/Meiningen_Gesellschaft/content/Screen01.ui.qml</file>
<file alias="components/ContentCarousel.qml">C:/QtProjects/Meiningen_Gesellschaft/content/components/ContentCarousel.qml</file>
<file alias="components/UpdateTimer.qml">C:/QtProjects/Meiningen_Gesellschaft/content/components/UpdateTimer.qml</file>
<file alias="components/VideoContainer.qml">C:/QtProjects/Meiningen_Gesellschaft/content/components/VideoContainer.qml</file>
<file alias="footage/ducks.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/ducks.mp4</file>
<file alias="footage/girl_talking.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/girl_talking.mp4</file>
<file alias="footage/steam.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/steam.mp4</file>
<file alias="footage/tea.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/tea.mp4</file>
<file alias="footage/thumbnails/ducks_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/ducks_thumbnail.jpg</file>
<file alias="footage/thumbnails/girl_talking_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/girl_talking_thumbnail.jpg</file>
<file alias="footage/thumbnails/steam_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/steam_thumbnail.jpg</file>
<file alias="footage/thumbnails/tea_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/tea_thumbnail.jpg</file>
</qresource>
</RCC>My Custom components and also my footage is listed as an alias and then given a full path. I have also tried the exe on another computer by just adding the required dll files and no footage. The footage was still present so I'm assuming its embeded. Just for my understanding if I have a path like the one on my post ex "../footage/image.jpg" the footage folder would have to be one folder prior to the exe right?
Thanks again for your time.
Edit: just as some extra infor the .qrc file is located in my build folder under "build/content/.rcc/content_raw_qml_0.qrc"
-
@jsulm So as far as I can tell a resource file is automatically generated either when I export the CMake build files or when I open the CMakeLists file in Qt Creator. I did not write one myself. This is how it looks:
<RCC>
<qresource prefix="/qt/qml/content/">
<file alias="App.qml">C:/QtProjects/Meiningen_Gesellschaft/content/App.qml</file>
<file alias="Screen01.ui.qml">C:/QtProjects/Meiningen_Gesellschaft/content/Screen01.ui.qml</file>
<file alias="components/ContentCarousel.qml">C:/QtProjects/Meiningen_Gesellschaft/content/components/ContentCarousel.qml</file>
<file alias="components/UpdateTimer.qml">C:/QtProjects/Meiningen_Gesellschaft/content/components/UpdateTimer.qml</file>
<file alias="components/VideoContainer.qml">C:/QtProjects/Meiningen_Gesellschaft/content/components/VideoContainer.qml</file>
<file alias="footage/ducks.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/ducks.mp4</file>
<file alias="footage/girl_talking.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/girl_talking.mp4</file>
<file alias="footage/steam.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/steam.mp4</file>
<file alias="footage/tea.mp4">C:/QtProjects/Meiningen_Gesellschaft/content/footage/tea.mp4</file>
<file alias="footage/thumbnails/ducks_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/ducks_thumbnail.jpg</file>
<file alias="footage/thumbnails/girl_talking_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/girl_talking_thumbnail.jpg</file>
<file alias="footage/thumbnails/steam_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/steam_thumbnail.jpg</file>
<file alias="footage/thumbnails/tea_thumbnail.jpg">C:/QtProjects/Meiningen_Gesellschaft/content/footage/thumbnails/tea_thumbnail.jpg</file>
</qresource>
</RCC>My Custom components and also my footage is listed as an alias and then given a full path. I have also tried the exe on another computer by just adding the required dll files and no footage. The footage was still present so I'm assuming its embeded. Just for my understanding if I have a path like the one on my post ex "../footage/image.jpg" the footage folder would have to be one folder prior to the exe right?
Thanks again for your time.
Edit: just as some extra infor the .qrc file is located in my build folder under "build/content/.rcc/content_raw_qml_0.qrc"
@danilo_jn if anyone is wondering, the right way to do this is:
source: "file:footage/image.png"
For it to work with QtDesign Studio simply create a folder called "footage" in the root of your project. Then when you build your app transfer that folder so it's right next to you exe.
-