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. Webassembly - QML contents are not being drawn until I start to move the mouse
Forum Updated to NodeBB v4.3 + New Features

Webassembly - QML contents are not being drawn until I start to move the mouse

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
3 Posts 3 Posters 415 Views
  • 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
    just_a_developer
    wrote on last edited by
    #1

    Hello,

    I am building my QML app for WebAssembly. Everything works fine, except that QML contents are not being drawn until I start to move the mouse.

    Is there any way to force drawing or to fix this issue in a different way?

    Thank you for any help in advance!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mujeek
      wrote on last edited by
      #2

      My QML app for WebAssembly shows the same behavior.
      I found a workaround which may or may not resolve your issue.
      All happens while application wasm is loaded, compiled and run.
      The html file controls this process.
      There are three sections in the html which Qt generates by default: qtspinner, qtstatus and qtcanvas.
      qtspinner shows Qt logo while wasm is loaded.
      qtstatus shows loading information (eg. loading, compiling, ...).
      qtcanvas is the area where application draws.
      The html body element contains property "onload=init()" which starts Wasm loading.
      Source code of script init() ends html body element.
      It builds a QtLoader object.
      Among QtLoader properties there is 'showCanvas' one, which hides qtspinner and shows qtcanvas when wasm app is ready to run.
      As you said and I confirm, browers (I tested Crome, Safari and Firefox) generate no redraw event while this switch happens, so user has to move mouse or tap or rotate screen (my app is a mobile one) to generate a redraw event.
      My workaround consists in adding a backgound image to qtcanvas which resembles wasm app output and suggests users to take an action. It may be a splash screen or something else, but its scope is clear: generate an event which starts things.
      I hope this may help you.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LubosD
        wrote on last edited by
        #3

        I had the same problem and I solved it like this:

        QQmlApplicationEngine engine;
        // do loading here...
        auto rootObject = engine.rootObjects().first();
        static_cast< QQuickWindow* >( rootObject )->raise();
        

        The root object is a QML Window.

        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