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. The main window freeze for a couple of seconds while opening/closing a dialog. What is a remedy?

The main window freeze for a couple of seconds while opening/closing a dialog. What is a remedy?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 2.6k 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
    mohmo
    wrote on last edited by
    #1

    Hey Bros,
    I have a main window with more than 200 elements that are updating every 500 milliseconds. The update includes changing the apparent (mostly the color) of every element by their Qpainter through an update function in main window.
    I have a widget window in main window that is invisible.
    when i click on these elements,that widget will be shown.
    but in the interval of showing/closing that widget, my main window freezes for some seconds.
    How can i solve this problem??
    Thanks a lot.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What kind of information are you showing ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        on my main window i show numbers and small symbols (more than 200 elements) that their color or icon is changing by their Qpainter.
        But i just have a couple of push buttons on my widget.
        is there to transfer my widget to a thread other than the main thread of main window?!! or this is a stupid idea?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No you can't paint widgets from another thread. However, you can generate the content to be painted (e.g. the Mandelbrot example)

          Out of curiosity, do you really need that much widgets ? Wouldn't a QGraphicsView/Scene combo be more suited ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mohmo
            wrote on last edited by
            #5

            Thanks Samuel,
            actually my application is like an "scada" system and every widget on the main window is symbol of a sensor.
            when the operator clicks on every widget(symbol), all data (such as temperature trend and ...) can be seen in the second window that will be opened. Now when i want to close that window (or while opening) the main window will freeze.

            I inherited that symbols from Qpushbutton.
            why do you suggest QGraphicsView/Scene?? you think at this situation, opening the second window will not cause the main window to freeze?!
            And really thanks for your clue of "mandelbrotwidget". that will help me in threading because my app needs that for reading from tcp/ip and writing to database.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Well, from what I remember of scada control screens, they can be graphically intensive and animated. The QGraphicsView framework would make more sense to do these kind of animations (or QML)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mohmo
                wrote on last edited by
                #7

                and for last question:
                assume you have a main window that an simple animation (such as moving a line) is shown. the moving (animation) process is performing through calling a function (AnimateFunc()) in main window by a Qtimer(500 ms). in this function (AnimateFunc()), the geometry of the line in the main window is changing randomly.
                Beside that, there is a dialog widget that is shown by a push botton in main window.
                the question:
                In the time of showing that dialog, the call for AnimateFunc() will be happened in every 800 ms or 900 ms and again returns to 500 ms.
                this happens because the gui thread is busy because of showing that dialog.
                How can i keep the calling interval time of AnimateFunc() fixed?
                what do you do as a specialist?
                using QGraphicsView, can i move them to separated threads??

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Not knowing the code nor the hardware, I can't really comment on that.

                  What does the dialog do ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mohmo
                    wrote on last edited by
                    #9

                    platform: windows
                    hardware: intel corei3 PC 32 bit
                    the dialog has 5 push buttons that are initiated (enabled/disabled) at the beginning of the show with 5 Boolean variables.it has an ok/cancel too.
                    when i click on ok, the variables take value with respect to the push buttons states. nothing more! the dialog has a style sheet too. it is inherited from QWidget and its parent is main window and i set it to Qt::Dialog.
                    i just set its visibility on or off. its made in the start of the application on the heap.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Sounds pretty lightweight…

                      And what does your main window do ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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