Here is the same question with a working example
https://codereview.stackexchange.com/questions/274781/qt-creating-a-dark-overlay-to-apply-on-top-of-other-widgets-with-animation