Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Friends help me, how does it do to execute a qml function from an Item inside a Parallel Thread to not freeze UI? help please

    General and Desktop
    3
    7
    924
    Loading More Posts
    • 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.
    • Everton Fonseca
      Everton Fonseca last edited by

      Friends help me, how does it do to execute a qml function from an Item inside a Parallel Thread to not freeze UI?

      example:

      Import QtQuick 2.7

      MyItem {

       Function foo () {
          
           // script
           For (var i = 0; i <1000000; i ++)
           {
               Console.log ( "Number:" + i)
              
           }
       } // end function
      

      } // end MyItem

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User last edited by

        Hi! See WorkerScript QML Type.

        1 Reply Last reply Reply Quote 2
        • Everton Fonseca
          Everton Fonseca last edited by

          More in Work Script I can not work with objects within a function. Is there any way for this?

          1 Reply Last reply Reply Quote 0
          • Everton Fonseca
            Everton Fonseca last edited by

            More in Work Script I can not work with objects within a function. Is there any way for this?

            MyItem {

            function foo () {

             // script 
            anotherObj.foo()
            

            } // end function

            } // end MyItem

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User last edited by A Former User

              No, more isn't possible because JS is single-threaded by design. These worker scripts (or web workers in other contexts) are more or less just a hackish work-around for that. Keep in mind that JS is meant only for very short / simple code. Executing it is very inefficient, so you should really do all the complicated non-GUI stuff in C++.

              1 Reply Last reply Reply Quote 2
              • Everton Fonseca
                Everton Fonseca last edited by

                So how do I call a function from an object without freezing my UI?

                V 1 Reply Last reply Reply Quote 0
                • V
                  vladstelmahovsky @Everton Fonseca last edited by

                  @Everton-Fonseca C++ and QRunnable

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post