I'm importing a portion of existing code into my Qt app and noticed a sleep function in there. Now after doing some researching I read that this type of function has no place in event programming. What should I do instead? Also, I am aware of QThread::sleep() [static protected] and subclassing it but I heard thats a hack and ends up doign the same thing. I am thinking trolltech had a reason to not offer easy access to sleep.
I would like to add this: I use the sleep between sending a UDP packet and receiving it. Also in all of this I see your points and I see one area where I will probably implement this but I think I found a situation where using sleep is not a problem and is my case for 95% of the program. First, lets say you have the main window. You click on a menu option to open up a window. The only time UDP packet will be read/writeen is after clicking on the menu option and before the desired window is displayed. Then there are no transfers for the entire time the window is open. At the end, the user presses SAVE and only then do we use UDP to send info back through UDP. So I hope you agree with me that this shouldnt create any problems. The only case I have found to not follow this is in only one of the many windows and it is a screen that displays data that is periodically refreshed ie every second a remote device is polled through UDP and this data is assigned to the views. So for this case I would understand, but its implemented and I havent seen any problems, oh and in any case these calls are in a separate thread and the the Main thread and QThread doesnt enable anything graphics related.
So after this analysis and your good info I would say the answer is: depends what you are doing.