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. Wasm not updating without an event (mouse, keyboard)
Qt 6.11 is out! See what's new in the release blog

Wasm not updating without an event (mouse, keyboard)

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
6 Posts 4 Posters 2.1k Views 2 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.
  • O Offline
    O Offline
    Ollie_A
    wrote on last edited by
    #1

    Hi, For the purposes of this question I'm trying to build a simple chat program (there is a little more underneath it but it -shouldn't- be relevant) in Qt, and port it to WASM. I'm using QtWidgets and QtWebSockets. The message gets sent from one instance of the client to a server, who then returns the message to any instances of the client connected to the chat. This works on a networking level; The message gets sent and received by the client, as I can see in the firefox debugger. The problem is that the WASM GUI made of QtWidgets won't update to reflect this until it receives a mouse event, such as movement or clicking, or a keyboard event. I have a QTextEdit chatbox which I append each message to. Messages will not appear in the chatbox until an event one such event is received, such as mousing over the browser. I also tried this with a QLabel, and had the same results of it not updating until moused over. Note that this is specific to WASM, as the clients running just in C++ work fine regardless of mouse events.

    What's weird is that it's still receiving messages; the debugger updates that message has been received in the websocket. I'm aware that websockets run on a separate JS level, but not only are the messages receieved, but WASM callback functions bound to when a message is received from the QWebSocket are run. This implies that my issue is just with the rendering to the screen.

    Does anyone know anything about this? Is it a known issue with QtWidgets in WASM? Is it a setting of the qt emscripten build? Any ideas would be greatly appreciated, as this doesn't seem like something I can easily debug just with the code. Cheers.

    JonBJ 1 Reply Last reply
    0
    • O Ollie_A

      Hi, For the purposes of this question I'm trying to build a simple chat program (there is a little more underneath it but it -shouldn't- be relevant) in Qt, and port it to WASM. I'm using QtWidgets and QtWebSockets. The message gets sent from one instance of the client to a server, who then returns the message to any instances of the client connected to the chat. This works on a networking level; The message gets sent and received by the client, as I can see in the firefox debugger. The problem is that the WASM GUI made of QtWidgets won't update to reflect this until it receives a mouse event, such as movement or clicking, or a keyboard event. I have a QTextEdit chatbox which I append each message to. Messages will not appear in the chatbox until an event one such event is received, such as mousing over the browser. I also tried this with a QLabel, and had the same results of it not updating until moused over. Note that this is specific to WASM, as the clients running just in C++ work fine regardless of mouse events.

      What's weird is that it's still receiving messages; the debugger updates that message has been received in the websocket. I'm aware that websockets run on a separate JS level, but not only are the messages receieved, but WASM callback functions bound to when a message is received from the QWebSocket are run. This implies that my issue is just with the rendering to the screen.

      Does anyone know anything about this? Is it a known issue with QtWidgets in WASM? Is it a setting of the qt emscripten build? Any ideas would be greatly appreciated, as this doesn't seem like something I can easily debug just with the code. Cheers.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Ollie_A said in Wasm not updating without an event (mouse, keyboard):

      I have a QTextEdit chatbox which I append each message to.

      I have no idea whether this will help or why you should have to do it, but is it worth calling QWidget::update(), or even QWidget::repaint(), to see if that reflects immediately?

      You may get a (better!) answer to this here, or you might have to await the expert @lorn-potter reading your topic....

      O 1 Reply Last reply
      0
      • JonBJ JonB

        @Ollie_A said in Wasm not updating without an event (mouse, keyboard):

        I have a QTextEdit chatbox which I append each message to.

        I have no idea whether this will help or why you should have to do it, but is it worth calling QWidget::update(), or even QWidget::repaint(), to see if that reflects immediately?

        You may get a (better!) answer to this here, or you might have to await the expert @lorn-potter reading your topic....

        O Offline
        O Offline
        Ollie_A
        wrote on last edited by
        #3

        @JonB Sorry for the late reply. I ended up using a timer ticking every 0.5 seconds that seemed to work, but that does also sound like it might have been in with a shot of working! Cheers.

        T 1 Reply Last reply
        0
        • O Ollie_A

          @JonB Sorry for the late reply. I ended up using a timer ticking every 0.5 seconds that seemed to work, but that does also sound like it might have been in with a shot of working! Cheers.

          T Offline
          T Offline
          tprohor
          wrote on last edited by tprohor
          #4

          @Ollie_A I have the same problem with update after web socket event. I solve it like this:

          for (auto pWindow : qApp->topLevelWindows()) {
              pWindow->requestUpdate();
          }
          
          1 Reply Last reply
          1
          • lorn.potterL Offline
            lorn.potterL Offline
            lorn.potter
            wrote on last edited by
            #5

            What version of Qt are you using?

            Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
            Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tprohor
              wrote on last edited by
              #6

              My version is 5.15.2

              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