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 let qtimer execute if under while loop
Forum Updated to NodeBB v4.3 + New Features

How to let qtimer execute if under while loop

Scheduled Pinned Locked Moved General and Desktop
17 Posts 4 Posters 6.2k Views 4 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.
  • Q Offline
    Q Offline
    Q139
    wrote on last edited by Q139
    #7

    Also would be good if opengl seperate thread , sometimes when lot of data displayed fps drop very low and slow gui but it only happenened so far on atom powered laptop or older hardware.

    Can please guide to some materials how to initialize opengl to seperate thread and how to initialize worker threads?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #8

      I think @SGaist meant the 'long calculation' part of your program in a separate thread.

      The GUI should not be split into different threads (including the openGl parts). I am not ever sure if you can actually have Qt GUI elements run in different threads (like QWidget). If this is possible you should avoid it. Threads should be used for long calculations or other non-GUI functions.

      If the openGl part is slow you should look into some method to pre-process your vertex data (display lists or the modern equivalent) to take some of the weight of the render function.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Q139
        wrote on last edited by Q139
        #9

        Opengl get slow if lot of data and drawing but no need for too much, wont fit on monitor anyway.

        Then will start to learn threading for worker part ,

        Gui can be main thread but nice if gl also seperate then gui not connected to gl fps drops.

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

          @Rondog is right about what I meant.

          QWidget can not be manipulated outside the GUI thread.

          In what case are you experiencing OpenGL slow-down ? Before trying to put everything in different threads you should analyze what you are doing in OpenGL, how are you feeding data to the GPU etc.

          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
          • Q Offline
            Q Offline
            Q139
            wrote on last edited by Q139
            #11

            Data to gpu is from ram generated to triangles , 2 triangles 1 line .
            If over 50 000 lines cpu get slow feeding and calculating for gpu , also ui refreshg rate drops but it no problem in normal operation .
            By taking calculating part away to seperate thread probably good enough to lose problems with gui refresh.

            If have time please answer few threading questions.

            If have created thread and try start it in main function by
            Calc_thread t_obj;
            t_obj.start();
            Is should have ran as with while(1) loop cpu rised.

            this is thread .h file
            #ifndef CALC_THREAD_H
            #define CALC_THREAD_H

            #include <QtCore>

            class Calc_thread : public QThread
            {
            public:
            Calc_thread();

               void run();
            

            };

            class Calc_Class
            {
            public:
            void graph_code_run();
            ....etc

            How could voids in Calc_Class be accessed on seperate thread if it is created once in main function?
            Or have to put all functions under Calc_thread class?

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

              Are you sure you're doing the jobs at the right places ? Generating everything with your CPU and then just use the GPU to show the result isn't the most efficient way to do things

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

              Q 1 Reply Last reply
              0
              • SGaistS SGaist

                Are you sure you're doing the jobs at the right places ? Generating everything with your CPU and then just use the GPU to show the result isn't the most efficient way to do things

                Q Offline
                Q Offline
                Q139
                wrote on last edited by Q139
                #13

                @SGaist Data comes from vector containers that are loaded from disk, not sure how to make program more efficient.
                Not sure how to acess other class under other thread, should it be named to same class as thread to acess it?

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

                  Do you read them once from the disk ?

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

                  Q 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Do you read them once from the disk ?

                    Q Offline
                    Q Offline
                    Q139
                    wrote on last edited by Q139
                    #15

                    @SGaist Yes , Once to ram to vectors further from ram.

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

                      What do you mean by "to vectors further from ram" ?

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

                      Q 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        What do you mean by "to vectors further from ram" ?

                        Q Offline
                        Q Offline
                        Q139
                        wrote on last edited by Q139
                        #17

                        @SGaist
                        From disk is loaded to vector containers in ram , then further from vectors for graph generation or for testing that takes calculating power.
                        Now it running seperate thread and in comparison to runnignsame thread as gui and opengl about 5% faster without forced gui refresh.
                        No need put opengl seperate thread , it works well together with gui thread.

                        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