Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QToolBar Class Reference
[QtGui module]

The QToolBar class provides a movable panel that contains a set of controls. More...

 #include <QToolBar>

Inherits QWidget.

Properties

  • 55 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

  • 195 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Public Slots

  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 38 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 1 protected slot inherited from QWidget

Detailed Description

The QToolBar class provides a movable panel that contains a set of controls.

Toolbar buttons are added by adding actions, using addAction() or insertAction(). Groups of buttons can be separated using addSeparator() or insertSeparator(). If a toolbar button is not appropriate, a widget can be inserted instead using addWidget() or insertWidget(); examples of suitable widgets are QSpinBox, QDoubleSpinBox, and QComboBox. When a toolbar button is pressed it emits the actionTriggered() signal.

A toolbar can be fixed in place in a particular area (e.g. at the top of the window), or it can be movable (isMovable()) between toolbar areas; see allowedAreas() and isAreaAllowed().

When a toolbar is resized in such a way that it is too small to show all the items it contains, an extension button will appear as the last item in the toolbar. Pressing the extension button will pop up a menu containing the items that does not currently fit in the toolbar. Note that only action based items will be shown in the menu. If only non-action based items are to appear in the extension menu (e.g. a QSpinBox), the extension button will appear as usual, but it will be disabled to indicate that some items in the toolbar are currently not visible.

See also QToolButton, QMenu, QAction, and Application Example.


Property Documentation

allowedAreas : Qt::ToolBarAreas

This property holds areas where the toolbar may be placed.

The default is Qt::AllToolBarAreas.

This property only makes sense if the toolbar is in a QMainWindow.

Access functions:

  • Qt::ToolBarAreas allowedAreas () const
  • void setAllowedAreas ( Qt::ToolBarAreas areas )

See also movable.

iconSize : QSize

This property holds size of icons in the toolbar.

The default size is determined by the application's style and is derived from the QStyle::PM_ToolBarIconSize pixel metric.

Access functions:

  • QSize iconSize () const
  • void setIconSize ( const QSize & iconSize )

movable : bool

This property holds whether the user can move the toolbar within the toolbar area, or between toolbar areas.

By default, this property is true.

This property only makes sense if the toolbar is in a QMainWindow.

Access functions:

  • bool isMovable () const
  • void setMovable ( bool movable )

See also allowedAreas.

orientation : Qt::Orientation

This property holds orientation of the toolbar.

The default is Qt::Horizontal.

This function should not be used when the toolbar is managed by QMainWindow. You can use QMainWindow::addToolBar() or QMainWindow::insertToolBar() if you wish to move a toolbar (that is already added to a main window) to another Qt::ToolBarArea.

Access functions:

  • Qt::Orientation orientation () const
  • void setOrientation ( Qt::Orientation orientation )

toolButtonStyle : Qt::ToolButtonStyle

This property holds the style of toolbar buttons.

The default is Qt::ToolButtonIconOnly.

Access functions:

  • Qt::ToolButtonStyle toolButtonStyle () const
  • void setToolButtonStyle ( Qt::ToolButtonStyle toolButtonStyle )

Member Function Documentation

QToolBar::QToolBar ( const QString & title, QWidget * parent = 0 )

Constructs a QToolBar with the given parent.

The given window title identifies the toolbar and is shown in the context menu provided by QMainWindow.

See also setWindowTitle().

QToolBar::QToolBar ( QWidget * parent = 0 )

Constructs a QToolBar with the given parent.

QToolBar::~QToolBar ()

Destroys the toolbar.

QAction * QToolBar::actionAt ( const QPoint & p ) const

Returns the action at point p. This function returns zero if no action was found.

See also QWidget::childAt().

QAction * QToolBar::actionAt ( int x, int y ) const

This is an overloaded member function, provided for convenience.

Returns the action at the point x, y. This function returns zero if no action was found.

void QToolBar::actionTriggered ( QAction * action )   [signal]

This signal is emitted when a toolbar button is pressed. The parameter holds the toolbar button's associated action.

QAction * QToolBar::addAction ( const QString & text )

Creates a new action with the given text. This action is added to the end of the toolbar.

QAction * QToolBar::addAction ( const QIcon & icon, const QString & text )

This is an overloaded member function, provided for convenience.

Creates a new action with the given icon and text. This action is added to the end of the toolbar.

QAction * QToolBar::addAction ( const QString & text, const QObject * receiver, const char * member )

This is an overloaded member function, provided for convenience.

Creates a new action with the given text. This action is added to the end of the toolbar. The action's triggered() signal is connected to member in receiver.

QAction * QToolBar::addAction ( const QIcon & icon, const QString & text, const QObject * receiver, const char * member )

This is an overloaded member function, provided for convenience.

Creates a new action with the icon icon and text text. This action is added to the end of the toolbar. The action's triggered() signal is connected to member in receiver.

QAction * QToolBar::addSeparator ()

Adds a separator to the end of the toolbar.

See also insertSeparator().

QAction * QToolBar::addWidget ( QWidget * widget )

Adds the given widget to the toolbar as the toolbar's last item.

Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.

See also insertWidget().

void QToolBar::allowedAreasChanged ( Qt::ToolBarAreas allowedAreas )   [signal]

This signal is emitted when the collection of allowed areas for the toolbar is changed. The new areas in which the toolbar can be positioned are specified by allowedAreas.

See also allowedAreas.

void QToolBar::clear ()

Removes all actions from the toolbar.

See also removeAction().

void QToolBar::iconSizeChanged ( const QSize & iconSize )   [signal]

This signal is emitted when the icon size is changed. The iconSize parameter holds the toolbar's new icon size.

See also iconSize and QMainWindow::iconSize.

QAction * QToolBar::insertSeparator ( QAction * before )

Inserts a separator into the toolbar in front of the toolbar item associated with the before action.

See also addSeparator().

QAction * QToolBar::insertWidget ( QAction * before, QWidget * widget )

Inserts the given widget in front of the toolbar item associated with the before action.

Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.

See also addWidget().

bool QToolBar::isAreaAllowed ( Qt::ToolBarArea area ) const

Returns true if this toolbar is dockable in the given area; otherwise returns false.

void QToolBar::movableChanged ( bool movable )   [signal]

This signal is emitted when the toolbar becomes movable or fixed. If the toolbar can be moved, movable is true; otherwise it is false.

See also movable.

void QToolBar::orientationChanged ( Qt::Orientation orientation )   [signal]

This signal is emitted when the orientation of the toolbar changes. The new orientation is specified by the orientation given.

See also orientation.

QAction * QToolBar::toggleViewAction () const

Returns a checkable action that can be used to show or hide this toolbar.

The action's text is set to the toolbar's window title.

See also QAction::text and QWidget::windowTitle.

void QToolBar::toolButtonStyleChanged ( Qt::ToolButtonStyle toolButtonStyle )   [signal]

This signal is emitted when the tool button style is changed. The toolButtonStyle parameter holds the toolbar's new tool button style.

See also toolButtonStyle and QMainWindow::toolButtonStyle.

QWidget * QToolBar::widgetForAction ( QAction * action ) const

Returns the widget associated with the specified action.

This function was introduced in Qt 4.2.

See also addWidget().


Member Function Documentation

QToolBar::QToolBar ( QWidget * parent, const char * name )

Constructs a QToolBar with the given parent and name.

QString QToolBar::label () const

Use windowTitle() instead.

See also setLabel().

void QToolBar::setLabel ( const QString & label )

Use setWindowTitle() instead.

See also label().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • 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. Qt 4.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 !
 
 
 
 
Partenaires

Hébergement Web