|  | Home

# QtToolBarManager Class Reference

The QtToolBarManager class provides toolbar management for main windows. More...

     #include <QtToolBarManager>

Inherits QObject.

- List of all members, including inherited members

### Public Functions

- QtToolBarManager ( QObject * parent = 0 )
- ~QtToolBarManager ()
- void addAction ( QAction * action, const QString & category )
- void addToolBar ( QToolBar * toolBar, const QString & category )
- QMainWindow * mainWindow () const
- void removeAction ( QAction * action )
- void removeToolBar ( QToolBar * toolBar )
- bool restoreState ( const QByteArray & state, int version = 0 )
- QByteArray saveState ( int version = 0 ) const
- void setMainWindow ( QMainWindow * mainWindow )
- QList<QToolBar *> toolBars () const

- 29 public functions inherited from QObject

### Additional Inherited Members

- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 signal inherited from QObject
- 1 public type inherited from QObject
- 4 static public members inherited from QObject
- 7 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

The QtToolBarManager class provides toolbar management for main windows.

The QtToolBarManager is typically used with a QtToolBarDialog which allows the user to customize the toolbars for a given main window. The QtToolBarDialog class's functionality is controlled by an instance of the QtToolBarManager class, and the main window is specified using the QtToolBarManager class's setMainWindow() function.

The currently specified main window can be retrieved using the mainWindow() function.

The toolbar manager holds lists of the given main window's actions and toolbars, and can add actions and toolbars to these lists using the addAction() and addToolBar() functions respectively. The actions can in addition be categorized acccording to the user's preferences. The toolbar manager can also remove custom actions and toolbars using the removeAction() and removeToolBar() functions.

Finally, the QtToolBarManager is able to save the customized state of its toolbars using the saveState() function as well as restore the toolbars' saved state using restoreState() function.

See also QtToolBarDialog.

## Member Function Documentation

### QtToolBarManager::QtToolBarManager ( QObject * parent = 0 )

Creates a toolbar manager with the given parent.

### QtToolBarManager::~QtToolBarManager ()

Destroys the toolbar manager.

### void QtToolBarManager::addAction ( QAction * action, const QString & category )

Adds the given action to the given category in the manager's list of actions. If the category doesn't exist it is created. Only non separator actions can be added. If the action is already added to the list, the function doesn't do anything.

See also removeAction().

### void QtToolBarManager::addToolBar ( QToolBar * toolBar, const QString & category )

Adds the given toolBar to the manager's toolbar list.

All the toolBar's actions are automatically added to the given category in the manager's list of actions if they're not already there. The manager remembers which toolbar the actions belonged to, so, when the toolBar is removed, its actions will be removed as well.

Custom toolbars are created with the main window returned by the mainWindow() function, as its parent.

See also removeToolBar().

### QMainWindow * QtToolBarManager::mainWindow () const

Returns the main window associated this toolbar manager.

See also setMainWindow().

### void QtToolBarManager::removeAction ( QAction * action )

Removes the specified action from the manager's list of actions. The action is also removed from all the registered toolbars. If the specified action is the only action in its category, that category is removed as well.

See also addAction().

### void QtToolBarManager::removeToolBar ( QToolBar * toolBar )

Removes the specified toolBar from the manager's list. All the actions that existed in the specified toolBar when it was added are removed as well.

See also addToolBar().

### bool QtToolBarManager::restoreState ( const QByteArray & state, int version = 0 )

Restores the saved state of the toolbar manager's toolbars. The version number is compared with the version number of the stored state.

Returns true if the version numbers are matching and the toolbar manager's state is restored; otherwise the toolbar manager's state is left unchanged and the function returns false.

Note that the state of the toolbar manager's toolbars should be restored before restoring the state of the main window's toolbars and dockwidgets using the QMainWindow::restoreState() function. In that way the restoreState() function can create the custom toolbars before the QMainWindow::restoreState() function restores the custom toolbars' positions.

See also saveState().

### QByteArray QtToolBarManager::saveState ( int version = 0 ) const

Saves the state of the toolbar manager's toolbars. The version number is stored as part of the data.

Identifies all the QToolBar and QAction objects by their object name property. Ensure that this property is unique for each QToolBar and QAction that you add using the QtToolBarManager.

Returns an identifier for the state which can be passed along with the version number to the restoreState() function to restore the saved state.

See also restoreState().

### void QtToolBarManager::setMainWindow ( QMainWindow * mainWindow )

Sets the main window upon which the toolbar manager operates, to be the given mainWindow.

See also mainWindow().

### QList<QToolBar *> QtToolBarManager::toolBars () const

Returns the manager's toolbar list.