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. GUI Application Freezes when QButton is pressed
Forum Updated to NodeBB v4.3 + New Features

GUI Application Freezes when QButton is pressed

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 597 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.
  • KiraK Offline
    KiraK Offline
    Kira
    wrote on last edited by
    #1

    Hello All,
    This is a very common question though would, like to start something in relevance of the issue that haven't been answered.
    There is start button on my application. When i start the application my UI freezes until the operation
    is completed. What i have read that slots execute in parallell so why the application freezes.
    My slots takes approximately 10 sec to execute as it contains lot of initilaiztions.
    What would be correct way to handle such scenarios.

    jsulmJ 1 Reply Last reply
    0
    • KiraK Kira

      Hello All,
      This is a very common question though would, like to start something in relevance of the issue that haven't been answered.
      There is start button on my application. When i start the application my UI freezes until the operation
      is completed. What i have read that slots execute in parallell so why the application freezes.
      My slots takes approximately 10 sec to execute as it contains lot of initilaiztions.
      What would be correct way to handle such scenarios.

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

      @Kira said in GUI Application Freezes when QButton is pressed:

      What i have read that slots execute in parallell

      No, they don't. If you have a long lasting operation, then do not execute it in main thread (GUI thread) execute it in another thread.

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

      KiraK 1 Reply Last reply
      4
      • jsulmJ jsulm

        @Kira said in GUI Application Freezes when QButton is pressed:

        What i have read that slots execute in parallell

        No, they don't. If you have a long lasting operation, then do not execute it in main thread (GUI thread) execute it in another thread.

        KiraK Offline
        KiraK Offline
        Kira
        wrote on last edited by
        #3

        @jsulm : Thanks for the reply. In my previous discussion over the forum i was having getting a time in main thread so i have got suggestion to save image using singnal/slot mechanism to save image because it would create a queued slot connection and images would be saved without getting a lag.
        So i got an impression that slot executes parallely.

        jsulmJ 1 Reply Last reply
        0
        • KiraK Kira

          @jsulm : Thanks for the reply. In my previous discussion over the forum i was having getting a time in main thread so i have got suggestion to save image using singnal/slot mechanism to save image because it would create a queued slot connection and images would be saved without getting a lag.
          So i got an impression that slot executes parallely.

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

          @Kira Yes, a signal is put into the queue and next time the event loop is executed the slot will be executed. But as soon as the slot is started it blocks the event loop until it finishes. So, if it needs a lot of time your UI will be blocked until it is finishes. In that time no other slots can be executed. A thread can't execute more than one method/function at the same time. That's why long lasting operations are usually moved to other threads and are not executed in the main thread.

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

          KiraK 1 Reply Last reply
          2
          • jsulmJ jsulm

            @Kira Yes, a signal is put into the queue and next time the event loop is executed the slot will be executed. But as soon as the slot is started it blocks the event loop until it finishes. So, if it needs a lot of time your UI will be blocked until it is finishes. In that time no other slots can be executed. A thread can't execute more than one method/function at the same time. That's why long lasting operations are usually moved to other threads and are not executed in the main thread.

            KiraK Offline
            KiraK Offline
            Kira
            wrote on last edited by
            #5

            @jsulm : Thanks for the clarity was very helpful

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved