Qmenubar pyqt 1

Qmenubar pyqt

menubar = self.menuBar() # create our menubar
file = menubar.addMenu("&File") # create a file menu
open = QAction("&Open", self) # create a QAction
open.setShortcut("Ctrl+O") # set a shortcut for it
file.addAction(open) # and add it to our menu

# create another one and add it again to our menu
save = QAction("&Save",self) 

# and if you want to connect your QActions to our slots you can do it like:
open.triggered.connect(lambda: self.yourfunction())

Here is what the above code is Doing:
1. We create a menubar
2. We create a menu and add it to our menubar
3. We create a QAction and add it to our menu
4. We create another QAction and add it to our menu
5. We connect our QActions to our slots

Similar Posts