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. Inserting Widgets in layout with ForLoop cause Freeze

Inserting Widgets in layout with ForLoop cause Freeze

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

    what can i do in order to fix this.
    i tried sending Widgets by signals so maybe Qt handle it.
    and also tried using ProcessEvent in my event loop but i know its too risky.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      We need some more information - how many widgets do you create? What do the widgets do? Some example code to reproduce the issue.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mahd96
        wrote on last edited by
        #3

        about 100 widgets each contains a text,Image,or some simple Widgets.

        CP71C aha_1980A 2 Replies Last reply
        0
        • M mahd96

          about 100 widgets each contains a text,Image,or some simple Widgets.

          CP71C Offline
          CP71C Offline
          CP71
          wrote on last edited by
          #4

          @mahd96 Hi
          Only for information.
          Is application for low performance system?

          1 Reply Last reply
          0
          • M mahd96

            about 100 widgets each contains a text,Image,or some simple Widgets.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @mahd96 don't use a loop, use a QTimer instead.

            Qt has to stay free or it will die.

            1 Reply Last reply
            1
            • M Offline
              M Offline
              mahd96
              wrote on last edited by
              #6

              how i replace a loop with timer? do you mean a queue that handled by a timer?

              JonBJ 1 Reply Last reply
              0
              • M mahd96

                how i replace a loop with timer? do you mean a queue that handled by a timer?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @mahd96
                Yes, @aha_1980 will mean something like that. Along the lines of: set the timer to a short period, each time it ticks pull, say, 10 widgets off your queue and insert, then the next batch comes a hundredth of a second later or whatever. By doing that the UI will not "freeze" from the user's point of view. Of course, if the user interacts with your page after the first bunch of widgets have been placed but before the rest have been added, you may not be a good place, so you will have to do something suitable about that....

                Just how long is your 100 widgets taking? Is the content of certain ones what is costly? Don't forget that, for example, if you are populating them with a list or images which are taking time, you can rearrange to place them initially with empty content and then do the costly population in the background/on a timer. Like web pages arrive initially, and only afterward the pictures get filled in, etc.

                1 Reply Last reply
                3

                • Login

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