[Question] WebAssembly Dynamically URL Change
-
wrote on 6 Sept 2022, 04:13 last edited by jhayar 9 Jun 2022, 04:16
Hi ,
I found out that webassembly runs on canvas element , it is just a drawing in a browser not actually an html page,you know that clicking buttons on canvas does not actually browsing pages , it is just changing the canvas drawing to another drawing , okay given the fact that this is a canvas UI, for a regular user that likes to bookmark everything informative pages , this is not helpful because even they bookmark the page it will run on the first page not the page they want.
for this i think we can solve this by changing the URL (for example button1 = http://my.url/app?myquery=page1 , then button2 = http://my.url/app?myquery=app2) when a user clicks the button on the canvas UI the URL change dynamically , and then once the user click refresh button from the browser ,
the QML or C++ will check the URL (for example , http://my.url/app?myquery=page2 ) and then start the page into page2 instead of page1is this even possible ?
Thanks
-
wrote on 8 Sept 2022, 07:52 last edited by
I haven't studied your solution, but you can try to add a mdi area how central widget in MainWindow class. I haven't tried this solution
-
I haven't studied your solution, but you can try to add a mdi area how central widget in MainWindow class. I haven't tried this solution
-
@Renio thanks for the reply , what is mdi area ?
maybe we can solve this if i can add JS file into main html file ? then if there's a way that QML can communicate to a JS code ? and JS code to QML ? would you know ?
thankswrote on 13 Sept 2022, 07:58 last edited by Renio@jhayar said in [Question] WebAssembly Dynamically URL Change:
@Renio thanks for the reply , what is mdi area ?
maybe we can solve this if i can add JS file into main html file?
The html file is generated in compiling time. You can modify this file, but next compiling you lost your changes
then if there's a way that QML can communicate to a JS code ? and JS code to QML ? would you know ?
thanksI don't know... sorry
-
wrote on 13 Sept 2022, 11:54 last edited by Karmo
Qt WebAssembly uses emscripten, so technically you can call any Javascript from your C++ code using emscripten API. See https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#interacting-with-code-call-javascript-from-native. Maybe that will help you change the query in the URL?
At least the opposite - reading URL query from C++ code is possible. That I have tested.
#include <emscripten/val.h> ... emscripten::val location = emscripten::val::global("location"); auto search = location["search"].as<std::string>();
For cross-platform code wrap the emscripten stuff in
#ifdef Q_OS_WASM
.
1/5