PDA

View Full Version : Refreshing program state after a certain amount of time



kremuwa
4th April 2010, 00:14
Good Evening and Happy Easter,

I'm working on a p2m client, and I made a class to represent particular downloaded files. After having the necessary data given by user, I want to show the info about added file in a table. I made such table, where 1 file = 1 row. Apart of file name, file size, output folder, there are some data which should change dynamically - amount of currently downloaded kBs, progress bar indicating how many percents of the file size were currently downloaded, file state (downloading, preparing, paused, error). I don't know what is the best way to do it. Should I refresh program state every x seconds? How?

squidge
4th April 2010, 00:34
Use a QTimer to update the ui every second - thats more CPU friendly.

kremuwa
4th April 2010, 18:49
But how to do it "in the background"? I mean, user is using the program all the time (he runs a lot of functions, slots, opens additional windows, etc.) but the ui is still updating (independently!).

kremuwa
9th April 2010, 15:30
Ok, I've taken a look on the QTimer class and it is really convienient and easy. Thank you for your response then, fatjuicymole.