In attached example there is QFrame on top of a native window. When that frame is hidden, the native window does not seem to get paintEvent() call and thus the frame remains visible.
However it gets repainted when ever mouse cursor leaves or enters the button that was used to toggle the visibility.
To reproduce, run attached example and click on the toggle button. The black rectangle does not disappear until mouse is moved off of the QPushButton.
There is also "QWidget::paintEngine: Should no longer be called" message printed and I don't know how to properly workaround this. This example is reduced from a bigger example which didn't output this message, but had exactly the same issue so it probably doesn't affect this at all.