I have a custom QWidget with a QTimer set up in the resizeEvent function. The basic functionality of it is to execute some code only when the user has finished resizing the window (which in turn affects this QWidget). The code looks something like this:

Qt Code:
  1. CustomWidget::CustomWidget() : QWidget {
  2.  
  3. resizeTimer = new QTimer;
  4. connect(resizeTimer, SIGNAL(timeout()), this, SLOT(resizeStopped()));
  5.  
  6. }
  7.  
  8. void CustomWidget::resizeEvent(QResizeEvent *event){
  9.  
  10. resizeTimer->start(5);
  11. functionA()
  12.  
  13. }
  14.  
  15. void CustomWidget::resizeStopped(){
  16. resizeTimer->stop();
  17. functionB();
  18. }
  19.  
  20. void CustomWidget::functionA(){
  21. //code
  22. }
  23. void CustomWidget::functionB(){
  24. //code
  25. }
To copy to clipboard, switch view to plain text mode 

What I expected to happen was, while the window/widget was being resized, the timer would keep being reset until the resizing was paused long enough for the timer to timeout (in this case, 5 ms). However, for some reason when I have low intervals such as the 5 ms here, functionB() will only be called after my mouse has been released (after resizing the window). Higher values such as 100 ms work as expected, functionB() is called while the mouse is still pressed.

I'm not complaining, this is exactly what I want to happen, however I have no idea why it is, so I'm afraid it might raise some issues in the future which will confuse me. Anyone have any ideas?

Some additional information, is that functionA and functionB take some time to finish, around 50 - 150 ms. I was thinking this might be 'blocking' the timeout somehow if it times out before the function A/B has finished executing. I really have no idea though.