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. [Question] WebAssembly Dynamically URL Change
Forum Updated to NodeBB v4.3 + New Features

[Question] WebAssembly Dynamically URL Change

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
5 Posts 3 Posters 925 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.
  • J Offline
    J Offline
    jhayar
    wrote on 6 Sept 2022, 04:13 last edited by jhayar 9 Jun 2022, 04:16
    #1

    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 page1

    is this even possible ?

    Thanks

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Renio
      wrote on 8 Sept 2022, 07:52 last edited by
      #2

      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

      J 1 Reply Last reply 10 Sept 2022, 01:06
      0
      • R Renio
        8 Sept 2022, 07:52

        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

        J Offline
        J Offline
        jhayar
        wrote on 10 Sept 2022, 01:06 last edited by
        #3

        @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 ?
        thanks

        R 1 Reply Last reply 13 Sept 2022, 07:58
        0
        • J jhayar
          10 Sept 2022, 01:06

          @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 ?
          thanks

          R Offline
          R Offline
          Renio
          wrote on 13 Sept 2022, 07:58 last edited by Renio
          #4

          @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 ?
          thanks

          I don't know... sorry

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Karmo
            wrote on 13 Sept 2022, 11:54 last edited by Karmo
            #5

            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 Reply Last reply
            0

            1/5

            6 Sept 2022, 04:13

            • Login

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