QToolBar Class ReferenceThe QToolBar class provides a movable panel containing widgets such as tool buttons. More... #include <qtoolbar.h> Inherits QDockWindow. Public Members
Properties
Detailed DescriptionThe QToolBar class provides a movable panel containing widgets such as tool buttons.
A toolbar is a panel that contains a set of controls, usually represented by small icons. It's purpose is to provide quick access to frequently used commands or options. Within a QMainWindow the user can drag toolbars within and between the dock areas. Toolbars can also be dragged out of any dock area to float freely as top-level windows. QToolBar is a specialization of QDockWindow, and so provides all the functionality of a QDockWindow. To use QToolBar you simply create a QToolBar as a child of a QMainWindow, create a number of QToolButton widgets (or other widgets) in left to right (or top to bottom) order and call addSeparator() when you want a separator. When a toolbar is floated the caption used is the label given in the constructor call. This can be changed with setLabel().
QToolBar * fileTools = new QToolBar( this, "file operations" ); fileTools->setLabel( "File Operations" ); fileOpenAction->addTo( fileTools ); This extract from the application/application.cpp example shows the creation of a new toolbar as a child of a QMainWindow and adding two QActions. You may use most widgets within a toolbar, with QToolButton and QComboBox being the most common. If you create a new widget on an already visible QToolBar, this widget will automatically become visible without needing a show() call. (This differs from every other Qt widget container. We recommend calling show() anyway since we hope to fix this anomaly in a future release.) QToolBars, like QDockWindows, are located in QDockAreas or float as top-level windows. QMainWindow provides four QDockAreas (top, left, right and bottom). When you create a new toolbar (as in the example above) as a child of a QMainWindow the toolbar will be added to the top dock area. You can move it to another dock area (or float it) by calling QMainWindow::moveDockWindow(). QDock areas lay out their windows in Lines. If the main window is resized so that the area occupied by the toolbar is too small to show all its widgets a little arrow button (which looks like a right-pointing chevron, '»') will appear at the right or bottom of the toolbar depending on its orientation. Clicking this button pops up a menu that shows the 'overflowing' items. QToolButtons are represented in the menu using their textLabel property, other QButton subclasses are represented using their text property, and QComboBoxes are represented as submenus, with the caption text being used in the submenu item. Usually a toolbar will get precisely the space it needs. However, with setHorizontalStretchable(), setVerticalStretchable() or setStretchableWidget() you can tell the main window to expand the toolbar to fill all available space in the specified orientation. The toolbar arranges its buttons either horizontally or vertically (see orientation() for details). Generally, QDockArea will set the orientation correctly for you, but you can set it yourself with setOrientation() and track any changes by connecting to the orientationChanged() signal. You can use the clear() method to remove all items from a toolbar.
See also QToolButton, QMainWindow, Parts of Isys on Visual Design, GUI Design Handbook: Tool Bar, and Main Window and Related Classes. Member Function Documentation
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Quarterly au hasardÉcrire un périphérique personnalisé d'E/SQt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.
CommunautéRessources
Liens utilesContact
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. | Qt 3.2 | |
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