I am attempting to add an item to the application menu-bar of a simple PyQt example. However, the following code does not seem to alter the menu-bar at all. The only item in the menu is "Python". Below is the bulk of the code, minus imports and instantiation.
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.resize(250, 150)
self.setWindowTitle('menubar')
self.modal = False
exit = QtGui.QAction( QtGui.QIcon('images/app_icon.png'), 'Exit', self )
exit.setShortcut('Ctrl+Q')
exit.setStatusTip('Exit application')
self.connect(exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))
menubar = self.menuBar()
file = menubar.addMenu('File')
file.addAction(exit)
I've also tried creating a new QMenuBar
and using the setMenuBar()
method to manually swap out the menu bar.
Any glaring mistakes in the above snippet?