I am developing a desktop application on macOS. I have a class that is a subclass of QMainWindow. Inside this window there are many dockwidgets. I need to set WindowModality to WindowModal, so user cannot interact with other opened windows. But my window has a menubar with many menus that have some QActions inside and when I setWindowModality(Qt::WindowModal) it automatically disables every action in menu and I need them to be enabled.
Can anybody provide some simple solution for this? Or it is not possible?
Thank you very much.
EDIT:
I have many windows in my application. I have a real main window from which you can open another window and also from that window another window. And here is the situation where i need my child windows to be modal. But they also have their own menubar which gets automatically disabled when window modality is turned on. Ive been googling it already maybe for 10 hours without any solution. I cannot test it but I guess that on windows the menubar would not disable because the native menu is quite different.
If there is no specific need of using
QWindow, then it'll be easier to achive this usingQDialogclass instead. UsingQDialogyou can simply show dialog as modal usingexec()method.EDIT: Basically, you can add
QMenuBarelement to everyQLayoutclass object usingQLayout::setMenuBarmethod. If you want to add menu bar toQDialog, you've got to set layout for your dialog, then programatically create desiredQMenuBarobject and pass it toQDialoglayout (which you can access usingQDialog::layoutmethod). Simple example below: