Python qt: actions

From wikinotes

Creating Actions
Actions deserve special mention outside of the controls section. Following similar conventions used in several programs, in Qt a QtGui.QAction is how you attach a function to menubars, toolbars, or hotkeys. If you make it in one place, it's a hop-skip-and jump away from having options to put it elsewhere, or attach a hotkey to it.

exitAction = QtGui.QAction( QtGui.QIcon('exit.png'), 'Exit', self)  # New QAction (quit)    (icon, label, parent) 
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect( self.close )

Action Indicators
Buttons and QLabel titles can have an action indicator (an underlined first letter). Simple make the first letter of the label's text an Ampersand (&).

QtGui.QLabel('&My Menu')				## 'M' will be underlined.