I'm learning PyQt5 at the moment and now I'm studying the QAction method in order to perform and action from the menu of my application
import sys
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
from PyQt5.QtGui import QIcon
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
exitAct = QAction(QIcon('exit.png'), '&Exit', self)
exitAct.setShortcut('Ctrl+Q')
exitAct.setStatusTip("Exit application")
exitAct.triggered.connect(qApp.exit)
self.statusBar()
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAct)
self.setGeometry(300,300,300,200)
self.setWindowTitle('Simple Menu')
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
What I'm wondering in QAction function and addMenu(), what is the '&' in '&Exit' and '&File' standing for ? Or at least are they necessary to be kept ? Even though I deleted them it didn't change anything to their appearance or to the action they were meant to perform
Because I see it very often in scripts written by other programmers am I missing something ?