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 update signal
Qt 6.11 is out! See what's new in the release blog

GUI update signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 3.0k Views 3 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Is it possible to recive signal each time right before qwidget gui gets updated?

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

      Hi
      You can make it possible.
      You can use an event filter to see when the paint event comes (to the widget in question). You could even emit a signal if you wish.

      Can I ask what the goal is with it ?

      ? 1 Reply Last reply
      3
      • mrjjM mrjj

        Hi
        You can make it possible.
        You can use an event filter to see when the paint event comes (to the widget in question). You could even emit a signal if you wish.

        Can I ask what the goal is with it ?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        @mrjj To update gui components without using timer that triggers update_gui function

        I would expect Qt has timer somewhere that goes 30hz-screen refresh rate to keep gui values changing.

        I don't believe it all is event driven

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

          Hi,

          No there's no timer involved in this case as it would not necessarily make sense. 30Hz is currently a "slow" monitor most of them are at 60 or more. There would also be no reason to trigger repainting of widgets that have not changed.

          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
          2
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            Many of the updates come from the OS (like wm_paint on windows ) and
            rest is triggered by calling update() in the widgets when a value is changed.
            There is no timer / continually redrawing involved with normal Widgets applications.

            1 Reply Last reply
            2
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by A Former User
              #6

              I set some values in a gui_update function.
              Like app runtime , TCP packet stats etc.
              But I never call QApplication::processevents()
              What would be best way to sync to GUI updates?
              Is windows setting some frequency?
              Or all event driven by my setting values of gui objects?

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

                Changing a variable in some random class does not mean Qt has to trigger any refresh. You can call the update method of the widget you just modified.

                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
                • SGaistS SGaist

                  Changing a variable in some random class does not mean Qt has to trigger any refresh. You can call the update method of the widget you just modified.

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by A Former User
                  #8

                  @SGaist In ui class on QLable->setText()

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

                    You should share the relevant part of your code.

                    You could be using a tight loop and thus block the event loop and the related widget updates.

                    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
                    1
                    • SGaistS SGaist

                      You should share the relevant part of your code.

                      You could be using a tight loop and thus block the event loop and the related widget updates.

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by A Former User
                      #10

                      ui.h

                      QTimer *uiRefreshTimer = new QTimer;
                      

                      ui.cpp setting window up

                            connect(uiRefreshTimer, SIGNAL(timeout()), this, SLOT(updateGui()));
                            uiRefreshTimer->start(ui->ui_refresh_rate->value());
                      

                      Gui refresh function, this code is partly 5-6 years old, some thing i now understand dont need to be there.
                      But networking packet stats and app runtime + some other stats i dont know how to update wiser.

                      
                      void MainWin::updateGui()
                      {
                          ui->appTimer->setText(CONVERT.GetTimeTextFromTimePassed(appStartTime));
                      
                          ui->infoLineTimer->setText(CONVERT.GetTimeTextFromTimePassed(lastConnectionTime));
                      
                          double fileProgress;
                          if(!fileLoader.loadingFiles){
                              fileProgress=1;
                              if(!ui->filesLoadingProgressBar->isHidden()){
                                  ui->filesLoadingProgressBar->setHidden(1);
                                  ui->fileLoadingETR->setHidden(1);
                              }
                          }else{
                              fileProgress=(double)fileLoader.loadingFilesCount/fileLoader.loadingFilesTotalCount;
                                  if(ui->filesLoadingProgressBar->isHidden()){
                                      ui->filesLoadingProgressBar->setHidden(0);
                                  }
                                  if(ui->fileLoadingETR->isHidden()&&fileProgress>0){
                                      ui->fileLoadingETR->setHidden(0);
                                  }
                                  ui->filesLoadingProgressBar->setValue(fileProgress*1000);
                                  ui->fileLoadingETR->setText(CONVERT.GetEstimatedTimeLeft(fileLoader.startTime,fileProgress));
                          }
                      
                          POINTERS.rHist->updateGui();
                      
                        //  uint DDminutes = r.Mana.time_in_data / 60000 ;
                       //   uint DDdays = DDminutes/1440;
                      
                          ui->mb->setText(n(TESTER.MEM.get_ram_mb_usage())+"Mb");
                      
                          ui->label_66->setNum((int)ccc.badtimingsOnLoad);
                      
                          ui->CC_calc_runs->setNum((int)STATS.Algo_runs);
                          ui->CC_draws->setNum((int)STATS.draws);
                          ui->CC_p_info_recived->setNum((int)STATS.p_info_recived);
                          ui->CC_p_info_request->setNum((int)STATS.p_info_requests);
                          ui->CC_ticks->setNum((int)STATS.Ticks);
                      
                      
                      
                      
                          /*
                          ui->label_24->setNum(PLAYER.current_gap/3600000);
                          if(PLAYER.current_gap > PLAYER.max_gap_length){
                              ui->label_24->setStyleSheet("background-color: red;");
                          }else{
                              ui->label_24->setStyleSheet("background-color: black;");
                          }*/
                      
                          //ui->tester_time_from_last_best->setText( CONVERT_TEXT.GetTimeTextFromTimePassed(TESTER.last_best_time_overall) );
                      
                      
                      
                      
                      
                      
                      if(TESTER.isRunning())
                      {
                          // thread info
                          QString info;
                          info.append(n(TESTER.threadPtrVec.size())+"  "+ speed +"\n");
                          for(uint e=0; e<TESTER.threadPtrVec.size(); e++){
                              RUNNER * ptr = TESTER.threadPtrVec[e];
                      
                              double progress = (double)ptr->dataAt/data_size;
                      
                              info += CONVERT.GetProgressbar(progress) +"\n";
                          }
                          ui->tester_info->setText(info);
                      
                          ui->tester_runtime->setText(CONVERT.GetTimeTextFromTimePassed(TESTER.testerStartedTime));
                      
                          ui->tester_runtime_cc->setNum((int)TESTER.tester_runtime_counter);
                          ui->tester_count_from_last_best->setNum((int)TESTER.tester_runtime_from_last_best_counter);
                      
                               case_nr_text.append(n(ss.case_number)  + "\t" + n(ss.extraAt)  + "\t" + n(ss.step)  + "\n" );
                          }
                      
                          ui->tester_case->setText(case_nr_text);
                      
                      }
                      
                      
                      
                      
                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Why not have your data sources signal that there's something new available ?

                        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
                        • SGaistS SGaist

                          Why not have your data sources signal that there's something new available ?

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by A Former User
                          #12

                          @SGaist New info avalible very often, also app runtime etc timers that display text.
                          I was hoping to sync to some timer that triggers gui refresh events and not use separate timer

                          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