Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Loading external web images...
QtWS25 Last Chance

Loading external web images...

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
3 Posts 2 Posters 85 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 Offline
    1 Offline
    1XU7
    wrote last edited by
    #1

    Hello!.

    I'm looking a way to separate all media files apart from .wasm to reduce file size ...
    My web app uses heavy weight images and i think is good idea to separate them from main file, so i was wondering if there is a way to put those images outside..

    Maybe something like this could be my root web directory:

    myWebApp.wasm
    image0.jpg
    image1.jpg
    etc...

    then in my code load it:

    Image {
                id: pic
                width: 300
                height: 300
                anchors.centerIn: root
                source: "./image0.jpg"
    }
    

    but no image is shown..

    A Resource File could be larger too, so it would partially solve the problem if i do a single resource file per image ?

    M 1 Reply Last reply
    0
    • 1 1XU7

      Hello!.

      I'm looking a way to separate all media files apart from .wasm to reduce file size ...
      My web app uses heavy weight images and i think is good idea to separate them from main file, so i was wondering if there is a way to put those images outside..

      Maybe something like this could be my root web directory:

      myWebApp.wasm
      image0.jpg
      image1.jpg
      etc...

      then in my code load it:

      Image {
                  id: pic
                  width: 300
                  height: 300
                  anchors.centerIn: root
                  source: "./image0.jpg"
      }
      

      but no image is shown..

      A Resource File could be larger too, so it would partially solve the problem if i do a single resource file per image ?

      M Offline
      M Offline
      mv-whw
      wrote last edited by mv-whw
      #2

      @1XU7 I dont think that you can use relative path to images if they are outside of main project (not inside resource file in project), because webassembly (.wasm project) is sandboxed and can see just what is inside "his" sandboxed filesystem.

      So i am not 100% on this but i think that only way to load external images is to specifie full path where there are hosted (for instance: myhost.com/images/image1.jpg)

      1 1 Reply Last reply
      2
      • M mv-whw

        @1XU7 I dont think that you can use relative path to images if they are outside of main project (not inside resource file in project), because webassembly (.wasm project) is sandboxed and can see just what is inside "his" sandboxed filesystem.

        So i am not 100% on this but i think that only way to load external images is to specifie full path where there are hosted (for instance: myhost.com/images/image1.jpg)

        1 Offline
        1 Offline
        1XU7
        wrote last edited by
        #3

        @mv-whw

        Thanks for answering
        Yes, that is the solution, putting inside my hosting public www folder all my resources:

        index.html
        main.wasm
        images/image0.png
        images/image1.png

        inside the wasm code:
        Image {
        source: "images/image0.png"
        }

        That worked well... and is very nice, this saves a lot of loading times..

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved