I just replaced the custom base class from QMenu to QWidget and the masking works properly, so apparently this issue is only coming with QMenu.
Is this a bug? Should i file a bug report?

Any ideas how to fix this issue?