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. How can i configure Qt Webassembly to use emscripten's file system api?
Forum Updated to NodeBB v4.3 + New Features

How can i configure Qt Webassembly to use emscripten's file system api?

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
4 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    ratemal
    wrote on 5 Mar 2022, 12:52 last edited by
    #1

    Hi, want my app to use indexedDB to store data inetween sessions, and in order to use it i have to explicitly enable it inside emscripten configuration. However, i have no idea how to actually do that using QT. The documentation says i should use "-lidbfs.js" to enable it, but i don't know where exactly should i put that line. Can someone please advise me how to do that?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lorn.potter
      wrote on 7 Mar 2022, 21:04 last edited by
      #2

      Are you using qmake or cmake?

      This presumes you have a javascript script that pre-mounts the filesystem, such as:
      https://codereview.qt-project.org/c/qt/qtbase/+/301981/3/src/plugins/platforms/wasm/presettings.js

      qmake, in your .pro file:

      QMAKE_LFLAGS += -s FORCE_FILESYSTEM=1 --pre-js presettings.js -lidbfs.js

      cmake, in CMakeFIles.txt:

      target_link_libraries(<put target name here> PRIVATE idbfs.js)
      target_link_options(<put target name here> PRIVATE --pre-js presettings.js)
      target_link_options(<put target name here> PRIVATE "SHELL:-s FORCE_FILESYSTEM=1 ")

      Change <put target name here> to what ever your apps 'target' name is.

      Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
      Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ratemal
        wrote on 8 Mar 2022, 13:54 last edited by
        #3

        Thanks a lot for help, but something still seems to be working incorrectly. I am trying to use EM_ASM to use the code directly in my cpp file like this

        EM_ASM(
                    FS.mkdir('/src');
                    FS.mount(IDBFS, {}, '/src');
                    FS.syncfs(true, function (err) {
                    });
                );
        

        However, the project refuses to build due to "use of undeclared identifier FS", apparently not recognizing the macro for what it is. If i do it using the js script you mentioned, does it mean i will now be able to interact with "/home/web_user/.config" file normally using

        file.open(QIODevice::ReadWrite);
        

        Or is there some other way i can access it inside my code

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lorn.potter
          wrote on 9 Mar 2022, 08:33 last edited by
          #4

          Maybe you need to add #include <emscripten.h>

          Yes, that script is for QSettings, but you could put /src in there as well.

          Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
          Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

          1 Reply Last reply
          0

          1/4

          5 Mar 2022, 12:52

          • Login

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