Creating Main Windows in Qt Designer |
Creating a Menu Double-click the placeholder item to begin editing. The menu text, displayed using a line edit, can be modified. | ||
Insert the required text for the new menu. Inserting an ampersand character (&) causes the letter following it to be used as a mnemonic for the menu. Press Return or Enter to accept the new text, or press Escape to reject it. You can undo the editing operation later if required. |
Menus can also be rearranged in the menu bar simply by dragging and dropping them in the preferred location. A vertical red line indicates the position where the menu will be inserted.
Menus can contain any number of entries and separators, and can be nested to the required depth. Adding new entries to menus can be achieved by navigating the menu structure in the usual way.
Creating a Menu Entry Double-click the new action placeholder to begin editing, or double-click new separator to insert a new separator line after the last entry in the menu. The menu entry's text is displayed using a line edit, and can be modified. | ||
Insert the required text for the new entry, optionally using the ampersand character (&) to mark the letter to use as a mnemonic for the entry. Press Return or Enter to accept the new text, or press Escape to reject it. The action created for this menu entry will be accessible via the Action Editor, and any associated keyboard shortcut can be set there. |
Just like with menus, entries can be moved around simply by dragging and dropping them in the preferred location. When an entry is dragged over a closed menu, the menu will open to allow it to be inserted there. Since menu entries are based on actions, they can also be dropped onto toolbars, where they will be displayed as toolbar buttons.
### SCREENSHOT
Toolbars ared added to a main window in a similar way to the menu bar: Select the Add Tool Bar option from the form's context menu. Alternatively, if there is an existing toolbar in the main window, you can click the arrow on its right end to create a new toolbar.
Toolbar buttons are created using the action system to populate each toolbar, rather than by using specific button widgets from the widget box. Since actions can be represented by menu entries and toolbar buttons, they can be moved between menus and toolbars. To share an action between a menu and a toolbar, drag its icon from the Action Editor to the toolbar rather than from the menu where its entry is located.
New actions for menus and toolbars can be created in the Action Editor.
With the menu bar and the toolbars in place, it's time to populate them with action: Qt Designer provides an action editor to simplify the creation and management of actions.
The Action Editor Enable the action editor by opening the Tools menu, and switching on the Action Editor option. The action editor allows you to create New actions and Delete actions. It also provides a search function, Filter, using the action's text. Qt Designer's action editor can be viewed in the classic Icon View and Detailed View. The screenshot below shows the action editor in Detailed View. You can also copy and paste actions between menus, toolbars and forms. |
To create an action, use the action editor's New button, which will then pop up an input dialog. Provide the new action with a Text -- this is the text that will appear in a menu entry and as the action's tooltip. The text is also automatically added to an "action" prefix, creating the action's Object Name.
In addition, the dialog provides the option of selecting an Icon for the action, as well as removing the current icon.
Once the action is created, it can be used wherever actions are applicable.
Adding an Action To add an action to a menu or a toolbar, simply press the left mouse button over the action in the action editor, and drag it to the preferred location. Qt Designer provides highlighted guide lines that tell you where the action will be added. Release the mouse button to add the action when you have found the right spot. |
Since dock widgets are container widgets, they can be added to a form in the usuasl way. Once added to a form, dock widgets are not placed in any particular dock area by default; you need to set the docked property to true for each widget and choose an appropriate value for its dockWidgetArea property.
Adding a Dock Widget To add a dock widget, simply drag one from the Containers section of the widget box, and drop it onto the main form area. Just like other widgets, its properties can be modified with the Property Editor. Dock widgets can be optionally floated as indpendent tool windows. Hence, it is useful to give them window titles by setting their windowTitle property. This also helps to identify them on the form. |
[Previous: Using Containers in Qt Designer] [Contents] [Next: Editing Resources with Qt Designer]
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. | Qt 4.5 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
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 ! |
Copyright © 2000-2012 - www.developpez.com