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. QApplication::processEvents() doesn't works
Forum Updated to NodeBB v4.3 + New Features

QApplication::processEvents() doesn't works

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
11 Posts 4 Posters 1.6k Views 3 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.
  • sitesvS sitesv

    Hi!
    Qt 5.15.2, 6.2.2
    Trying to execute function with processEvets() inside... Executing is freezing...

    while(!flag){
          QApplication::processEvents();
    }
    

    What should I do to fix this behaviour?
    Thank you!

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @sitesv said in QApplication::processEvents() doesn't works:

    What should I do to fix this behaviour?

    Get rid of the loop

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    sitesvS 1 Reply Last reply
    2
    • jsulmJ jsulm

      @sitesv said in QApplication::processEvents() doesn't works:

      What should I do to fix this behaviour?

      Get rid of the loop

      sitesvS Offline
      sitesvS Offline
      sitesv
      wrote on last edited by sitesv
      #3

      @jsulm I have to wait till the message parts (incoming messages from qwebsocket) will be collected. Is there another way?

      KroMignonK 1 Reply Last reply
      0
      • sitesvS sitesv

        @jsulm I have to wait till the message parts (incoming messages from qwebsocket) will be collected. Is there another way?

        KroMignonK Offline
        KroMignonK Offline
        KroMignon
        wrote on last edited by KroMignon
        #4

        @sitesv said in QApplication::processEvents() doesn't works:

        Is there another way?

        What's wrong with signals/slots mechanism?

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        sitesvS 1 Reply Last reply
        1
        • KroMignonK KroMignon

          @sitesv said in QApplication::processEvents() doesn't works:

          Is there another way?

          What's wrong with signals/slots mechanism?

          sitesvS Offline
          sitesvS Offline
          sitesv
          wrote on last edited by sitesv
          #5

          @KroMignon
          I want to create a function for sending request and receiving answer. That's why.

          KroMignonK 1 Reply Last reply
          0
          • sitesvS sitesv

            @KroMignon
            I want to create a function for sending request and receiving answer. That's why.

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #6

            @sitesv said in QApplication::processEvents() doesn't works:

            I want to create a function for sending request and receiving answer. That's why.

            Not really.
            You could use a local QEventLoop and exit the loop when signal is emitted.

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            sitesvS 1 Reply Last reply
            1
            • KroMignonK KroMignon

              @sitesv said in QApplication::processEvents() doesn't works:

              I want to create a function for sending request and receiving answer. That's why.

              Not really.
              You could use a local QEventLoop and exit the loop when signal is emitted.

              sitesvS Offline
              sitesvS Offline
              sitesv
              wrote on last edited by sitesv
              #7

              @KroMignon
              There is a problem with QEventLoop exec()
              I can't exit by emitting signal. And browser console says: "Uncaught Please compile your program with async support in order to use asynchronous operations like emscripten_sleep"

              Made something like this:

              bool myclass::func(){
                    ....
                   QEventLoop el;
                   connect(this, &myclass::mysignal, &el, &QEventLoop::exit));
                  el.exec();
              
                  /// unreachable string
              }
              
              void myclass::recieve_msg(const QByteArray &message){
                   ...
                   emit mysignal(0);
              }
              

              msvc compiled app works fine.

              Glad to see any advice.

              1 Reply Last reply
              0
              • lorn.potterL Offline
                lorn.potterL Offline
                lorn.potter
                wrote on last edited by
                #8

                secondary event loops are not really supported in emscripten. In Qt, you can run them, but they never return, or they won't return to the place you expect, as we needed to raise a javascript exception to pop out of it and return to the main loop.

                You might try Qt 6.3 and reconfiguring with asyncify ( -device-option QT_EMSCRIPTEN_ASYNCIFY=1 ), which has workarounds for Emscripten event loop.

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

                sitesvS 1 Reply Last reply
                0
                • lorn.potterL lorn.potter

                  secondary event loops are not really supported in emscripten. In Qt, you can run them, but they never return, or they won't return to the place you expect, as we needed to raise a javascript exception to pop out of it and return to the main loop.

                  You might try Qt 6.3 and reconfiguring with asyncify ( -device-option QT_EMSCRIPTEN_ASYNCIFY=1 ), which has workarounds for Emscripten event loop.

                  sitesvS Offline
                  sitesvS Offline
                  sitesv
                  wrote on last edited by sitesv
                  #9

                  @lorn-potter Thank you for an advice!
                  Could you please help me about reconfiguring?

                  Did you mean a rebuilding qt from sources with this key?

                  1 Reply Last reply
                  0
                  • sitesvS Offline
                    sitesvS Offline
                    sitesv
                    wrote on last edited by sitesv
                    #10

                    Trying to do next:
                    C:\Qt\6.3.0>\Src\configure.bat -qt-host-path C:\Qt\6.3.0\wasm_32 -no-warnings-are-errors -platform wasm-emscripten -device-option QT_EMSCRIPTEN_ASYNCIFY=1 -prefix C:\Qt\6.3.0\wasm_32_asyncify

                    But there is an error message:
                    CMake Error at qtbase/cmake/QtToolHelpers,cmake:156 (message): The tool "Qt6::moc" was not found in the Qt6CoreTools package.
                    ...

                    CMakeError.log

                    sitesvS 1 Reply Last reply
                    0
                    • sitesvS sitesv

                      Trying to do next:
                      C:\Qt\6.3.0>\Src\configure.bat -qt-host-path C:\Qt\6.3.0\wasm_32 -no-warnings-are-errors -platform wasm-emscripten -device-option QT_EMSCRIPTEN_ASYNCIFY=1 -prefix C:\Qt\6.3.0\wasm_32_asyncify

                      But there is an error message:
                      CMake Error at qtbase/cmake/QtToolHelpers,cmake:156 (message): The tool "Qt6::moc" was not found in the Qt6CoreTools package.
                      ...

                      CMakeError.log

                      sitesvS Offline
                      sitesvS Offline
                      sitesv
                      wrote on last edited by sitesv
                      #11

                      @sitesv said in QApplication::processEvents() doesn't works:

                      Trying to do next:
                      C:\Qt\6.3.0>\Src\configure.bat -qt-host-path C:\Qt\6.3.0\wasm_32 -no-warnings-are-errors -platform wasm-emscripten -device-option QT_EMSCRIPTEN_ASYNCIFY=1 -prefix C:\Qt\6.3.0\wasm_32_asyncify
                      But there is an error message:
                      CMake Error at qtbase/cmake/QtToolHelpers,cmake:156 (message): The tool "Qt6::moc" was not found in the Qt6CoreTools package.

                      This Q was solved. There is an error in qt host parameter...

                      But problem with QEventLoop still exist...

                      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