Opening File Dialog crashes App using Qt for web assembly and emsdk with upstream backend
-
Hi everyone,
I already asked this from here
Following the whole install process described here (thanks Lorn), I successully managed to get things to build fast...
I'm currently trying to access my local files from my application, as I saw it can be done using (cf "Slate" example, which I can build from QtCreator).
import Qt.labs.platform 1.0 as Platform (...) Platform.FileDialog { id: openProjectDialog objectName: "openProjectDialog" nameFilters: ["All files (*)", "JSON files (*.json)"] defaultSuffix: "json" }
But I can't access my file/folder system, same when I build the Slate app. Both app crash, and the mozilla firefox console gives me this:
When I build simply the Qt source without the upstream backend (following Qt for web assembly wiki), even though it takes almost 15minutes to build and link, I manage to access my files from the browser with the Slate app.
(But my custom app only gives me this with the qt wiki build, but that's another post... or a quick answer, up to you ;) )
My config:
Qt 5.13.1
latest emsdk with upstream 1.39.0
macOS X Sierra 10.12.6
XCode clang :
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/binThe wasm-emscripten works fine during the Qt sources build, as it builds beautifully with em++/emcc.
Is it my setup limitation (llvm 8.00 ) ? I thought you didn't have to an up-to-date (or custom-built) version of llvm with the upstream build...
Thank you all.
-
What you want is QFileDialog::getOpenFileContent
https://doc.qt.io/qt-5/qfiledialog.html#getOpenFileContentAll other QFileDialog functions will only access the sandbox filesystem.
Also you need to use this fork of slate:
https://github.com/msorvig/slate/tree/91114315b078680a7d40e41e805e8bb3a98c5815 -
Thanks for the answer. I can now access my files but QFile can't open the json files I'm looking to process.
When using the getOpenFilenContent, I have this in the web browser console:
RuntimeError: unreachable executed qtloader.js line 270 > WebAssembly.compile:10489242:1
There is something I don't understand. Why could I build the Slate example, open files with the Qt Labs FileDialog and use QFile API, but now that I use emscripten I just can't... pretty frustrating.
Is there a work around to QFile to be able to parse/use local files in the browser ?
Thanks a lot.