One of the most useful basic features of Qt is the support for buddy widgets. At the simplest level, a buddy widget accepts the input focus on behalf on a QLabel when the user types the label's shortcut key combination. The buddy concept is also used in Qt's model/view framework.
To enter buddy editing mode, open the Edit menu and select Edit Buddies. This mode presents the widgets on the form in a similar way to the signals and slots editing mode except that, in this mode, connections must start at label widgets. Ideally, you should connect each label widget that provides a shortcut with a suitable input widget, such as a QLineEdit.
Making Buddies
To define a buddy widget for a label, click on the label, drag the connection to another widget on the form, and release the mouse button. The connection shown indicates how the input focus is passed to the buddy widget.
You can use the form preview to test the connections between each label and its buddy.
Removing Buddy Connections
Only one buddy widget can be defined for each label. To change the buddy used, it is therefore necessary to delete any existing buddy connection and create a new one.
Connections between labels and their buddy widgets can be deleted in the same way as signal-slot connections in signals and slots editing mode: Select the buddy connection by clicking on it, and press the Delete key. This operation does not modify either the label or its buddy in any way.
Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).
Qt dans le magazine
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter
ou par MP !