Gustavo Amgarten
Gustavo Amgarten

Reputation: 406

PySide MainWindow doesn't create Menu Bar

I'm trying to create a menuBar on a MainWindow widget, but after writing the code I found on the internet, nothing seems to happen, the Menu Bar isn't created, even though no error message is displayed.

The code I use to create the UI with the menu bar is as follows:

def initUI(self):

    QToolTip.setFont(QFont("SansSerif", 10))

    self.setCentralWidget(QWidget())

    #Create the action to use on the menu bar
    exitAction = QAction(QIcon("logo.png"), "&Exit", self)
    exitAction.setShortcut("Cmd+Q")
    exitAction.setStatusTip("Close the application.")
    exitAction.triggered.connect(self.close)

    #Create status bar
    self.statusBar()

    #Attempt to create menu bar, but nothing happens.
    menuBar = self.menuBar()
    fileMenu = menuBar.addMenu("&File")
    fileMenu.addAction(exitAction)

    #Set MainWindow properties.
    self.setGeometry(0, 0, 250, 150)
    self.setWindowTitle("Icon")
    self.setWindowIcon(QIcon("logo.png"))
    self.setToolTip("This is the <b>Main Window</b>.")

    self.show()

EDIT: I'm using OSX.

Upvotes: 2

Views: 571

Answers (1)

Gustavo Amgarten
Gustavo Amgarten

Reputation: 406

Ok, it seems the problem is that I'm using OSX, and they filter some keywords.

For a more detailed answer, please check this one, as it explained it to me: Why doesn't menu get added?

Upvotes: 0

Related Questions