According to the documentation, QWidget::repaint should immediately call QWidget::paintEvent. (As opposed to QWidget::update, which puts a paint request on the event loop.) I am seeing this behavior on Windows, but on Mac, repaint appears to behave identically to update, i.e. it postpones the paint request until later.
The expected output (which happens on Windows and X11) would be:
The actual output is:
If I call qApp->processEvents() immediately after the repaint, then it works. But this obviously has other side-effects. In this sample application it is no big deal, but in my actual application I need an immediate repaint; an update will not do.
I am also seeing similar behavior in X11, although this sample code works there. I was not able to create a simple application that could reproduce the behavior, but X11 has a similar problem where you must call qApp->syncX() to get the repaint to take effect.