Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make signal slot work faster
Forum Updated to NodeBB v4.3 + New Features

How to make signal slot work faster

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.7k 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.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    I wrote one qt application which has two threads.
    Main thread/GUI thread which typically launches one QWebView window and plays some movie in youtube website. Another thread is the worker thread which is connected to some server and getting x,y,w,h rectangle info, and then I am emitting signals to main thread to reposition the QWebView window based on this coordinates.

    My problem is when I emit the signal to main thread, main thread takes approx 1~2 mins of delay to process that emitted signlas, because of that I am seeing slowness in the repositioning of my QWebView window.

    Please advice how can I make my main therad to act on this emitted signal immediately.

    Note :- I tried to reposition the QWebView window from the worker thread itself , but looks like Qt doesnt allow to access GUI elements to be accessed from worker threads.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You need to:

      Make sure not to overload the system with signals. Don't emit more of these inter-thread signals that you really need.

      Make sure that the main thread returns to the eventloop frequently. The eventloop is needed for cross-thread signals.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aashish.lg
        wrote on last edited by
        #3

        Thanks Andre for the suggestion, but would you please elaborate more on how can I make my GUI thread to return to event loop frequently.
        I am not gettiing any way to do so.

        Any help will be greatly appriciated.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          To make sure you return to the event loop, you:

          • Make sure you don't do bussy waiting
          • Don't use the waitFor... methods in the Qt API, but use asynch methods instead
          • Break up long operations in smaller bits and return to the event loop inbetween
          • Offload longer operations to separate threads, and perform these asynch again

          These are just some tips. It depends on your application what would give you the most milage. You'll have to do some profiling to find out, I guess.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aashish.lg
            wrote on last edited by
            #5

            But I am just playing a youtube video in a QWebView window using gui therad, thats it.
            How can I split this task even further in the smaller pireces or can look for Async way. I guess this is up to the qt web view to make gui thread busy based on video being played and makes it free accordingly.

            I observed more slowness when I play high defination video in youtube.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              That is going to be a problem then: your GUI thread is obviously very bussy with the webview and the embedded video. There is not much you can do about that. Sorry.

              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