PySide.QtGui.QLabel is used for displaying text or an image. No user interaction functionality is provided. The visual appearance of the label can be configured in various ways, and it can be used for specifying a focus mnemonic key for another widget.

In this example, keyboard focus is transferred to the label’s buddy (the PySide.QtGui.QLineEdit ) when the user presses Alt+P. If the buddy was a button (inheriting from PySide.QtGui.QAbstractButton ), triggering the mnemonic would emulate a button click.

When the user presses the shortcut key indicated by this label, the keyboard focus is transferred to the label’s buddy widget.

The buddy mechanism is only available for QLabels that contain text in which one character is prefixed with an ampersand, ‘&’. This character is set as the shortcut key. See the QKeySequence.mnemonic() documentation for details (to display an actual ampersand, use ‘&&’).

In a dialog, you might create two data entry widgets and a label for each, and set up the geometry layout so each label is just to the left of its data entry widget (its “buddy”), for example:

Sets the label contents to plain text containing the textual representation of double num . Any previous content is cleared. Does nothing if the double’s string representation is the same as the current contents of the label.

Sets the label contents to plain text containing the textual representation of integer num . Any previous content is cleared. Does nothing if the integer’s string representation is the same as the current contents of the label.

If a buddy has been set, the buddy mnemonic key is updated from the new text.

Note that PySide.QtGui.QLabel is well-suited to display small rich text documents, such as small documents that get their document specific settings (font, text color, link color) from the label’s palette and font properties. For large documents, use PySide.QtGui.QTextEdit in read-only mode instead. PySide.QtGui.QTextEdit can also provide a scroll bar when necessary.

If a buddy has been set, the buddy mnemonic key is updated from the new text.

Note that PySide.QtGui.QLabel is well-suited to display small rich text documents, such as small documents that get their document specific settings (font, text color, link color) from the label’s palette and font properties. For large documents, use PySide.QtGui.QTextEdit in read-only mode instead. PySide.QtGui.QTextEdit can also provide a scroll bar when necessary.