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 1.0k 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 last edited by jhayar
    #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
    • RenioR Offline
      RenioR Offline
      Renio
      wrote on 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
      0
      • RenioR Renio

        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 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

        RenioR 1 Reply Last reply
        0
        • J jhayar

          @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

          RenioR Offline
          RenioR Offline
          Renio
          wrote on 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 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

            • Login

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