Unsolved GUI update signal
-
Is it possible to recive signal each time right before qwidget gui gets updated?
-
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 ?
-
@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
-
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.
-
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. -
I set some values in a gui_update function.
Like app runtime , TCP packet stats etc.
But I never callQApplication::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? -
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.
-
@SGaist In ui class on
QLable->setText()
-
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.
-
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); }
-
Why not have your data sources signal that there's something new available ?
-
@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