简体   繁体   中英

Click on Python and File in MenuBar of a Qt windows not working on Mac OS

I Have an issue on Mac OS when I try to click on my menubar, nothing happend. I have two menus on named File and Load/Save but when I click on these the submenu don't show up. Although it works on windows and linux OS. So I'm suspecting something must be done for MAC, but I don't uberstand what? Even clicking on the 'python' button don't do anything.

Here is a screenshot to better see what I meant: [![enter image description here][1]][1]

and here the begining of the soft:

class SurfViewer(QMainWindow):
    def __init__(self, parent=None):
        super(SurfViewer, self).__init__()
        self.parent = parent

        ############variable utiles###########
        self.height_per_line = 20
        self.height_add = 30
        self.width_per_col =155
        self.List_Stim = []
        self.NewStim = None
        self.List_ParamEvol = []
        self.NewParamEvol = None
        #######################################
        #######################################

        self.centralWidget = QWidget()
        self.color = self.centralWidget.palette().color(QPalette.Background) 


        # toolbarmenu
        extractAction = QAction("ScreenShot", self)
        extractAction.triggered.connect(self.screenshot)

        extractLoadmodelparam = QAction("Load Model parameters", self)
        extractSavemodelparam = QAction("Save Model parameters", self)
        extractLoadStimparam = QAction("Load Stimulation parameters", self)
        extractSaveStimparam = QAction("Save Stimulation parameters", self)
        extractLoadparamEvol = QAction("Load parameters evolution", self)
        extractSaveparamEvol = QAction("Save parameters evolution", self)
        self.extractLoadResult = QAction("Load Result signals", self)
        self.extractLoadResult.setEnabled(True)
        self.extractSaveResult = QAction("Save Result signals", self)
        self.extractSaveResult.setEnabled(False)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(extractAction)
        fileLoad = menubar.addMenu('&Load/Save')
        fileLoad.addAction(extractSavemodelparam)
        fileLoad.addAction(extractLoadmodelparam)
        fileLoad.addAction(extractSaveStimparam)
        fileLoad.addAction(extractLoadStimparam)
        fileLoad.addAction(extractSaveparamEvol)
        fileLoad.addAction(extractLoadparamEvol)
        fileLoad.addAction(self.extractSaveResult)
        fileLoad.addAction(self.extractLoadResult)

        # set Tabs
        self.centralTabs= QTabWidget()
        self.setCentralWidget(self.centralTabs)

.... Some other stuffs after

I finally found a solution. Apparently, their is an issue with mac OS regarding to its way to handle menubar. So I set the setNativMenuBar to false in the code:

menubar.setNativeMenuBar(False)

Like that the menubar is still inside the windows (top left corner of the window) instead being at the top of the screen (detached from the software window itself)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM