I am building an Qt Application using WebAssembly. I want to open a local file and read it frin my code which isn't exacty easy with WebAssembly. I tried using the preload-file option (reference) in my .pro file:
CONFIG += preload-file /path/to/file/Settings.ini
However, when compiling my application with WebAssembly, It fails showing my the following error:
Application exit (RuntimeError: Aborted(native code called abort()))
I am currently using Qt 6 with the fitting Emscripten version. My code works when compiling with GCC. Of course, emscripten compiles when removing the file handling stuff from my code. Using a file dialog isn't a suitable option.
I noticed you are using CONFIG +=
but the emscripten reference says it is a linker flag. Try using instead QMAKE_LFLAGS += --preload-file /path/to/file/Settings.ini
.
Personally, I have not tested preload-file option but two other options have been working for me:
QMAKE_LFLAGS += --embed-file ../../cdpcore/Templates/Models@Models
to make the folder specified to be available in [working directory]/Models.RESOURCES += resources.qrc
.