Jonathan Jonathan - 1 year ago 52
Python Question

Using an '&' in a string in python

What is the purpose of the '&' in the string in this line?

exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)

Likewise here:

fileMenu = menubar.addMenu('&File')

Answer Source

The & character has a special purpose if you use it in the text of a QAction object: If the QAction object is used in a tool button, the character directly after the & symbol can be used as a keyboard shortcut for that button (in combination with the alt-key).

See (resp.