Qt5: How to do a cleanup manager (1 or more tasks) that run periodically to do cleaning-job?

93 views Asked by At

I am using Qt5 under Windows7.
I need to implement some kind of cleanup manager for my application.
It will be "activated" let's say once per hour, in order to perform some cleanup job(s): trim history if it's > 1000 lines, delete records form a database if older than 30 days and other things like this...
How should I do it in order to be flexible (to allow future cleaning tasks to be added later) and also to have minimal/reasonable impact on the application performance, i.e.: application is kinda multitasking server doing TCP connections and database connections, etc and I don't want the cleanup manager/task(s) to have some negative impact on the overall application speed/performance.
But ok, let's say a short time drop in performance would be acceptable as long as the user/client won't complain about such aspects :)
I am novice in Qt programming... I was thinking about using QTimer that periodically triggers a QTask/Qthread or something...?
Regards, Stanley.

1

There are 1 answers

3
Vikram On

You are on right track you can use QTimer to trigger a cleanup slot in you cleanup manager. you can keep adding different slots for different cleanup activity. Looking at you query it seems it better to have all you cleanup task in threads so that cleanup will be done async and will have less impact on performance.