Commit d954fee4 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - toolbars now store their child widgets and delete them themself as QT does not do it.

parent 9eea4484
......@@ -89,7 +89,7 @@ void WMainWindow::setupGUI()
setWindowIcon( m_iconManager.getIcon( "logo" ) );
setWindowTitle( QApplication::translate( "MainWindow", "OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
m_menuBar = new QMenuBar( 0 );
m_menuBar = new QMenuBar( this );
QMenu* fileMenu = m_menuBar->addMenu( "File" );
fileMenu->addAction( m_iconManager.getIcon( "load" ), "Load", this, SLOT( openLoadDialog() ), QKeySequence( "Ctrl+L" ) );
fileMenu->addAction( m_iconManager.getIcon( "quit" ), "Quit", this, SLOT( close() ), QKeySequence( "Ctrl+Q" ) );
......
......@@ -51,8 +51,22 @@ WQtPushButton* WQtToolBar::addPushButton( QString name, QIcon icon, QString labe
return button;
}
QAction* WQtToolBar::addWidget( QWidget* widget )
{
m_widgets.push_back( widget );
return QToolBar::addWidget( widget );
}
void WQtToolBar::clearButtons()
{
// iterate all items and delete them
for ( std::list< QWidget* >::iterator it = m_widgets.begin(); it != m_widgets.end(); ++it )
{
delete ( *it );
}
// clear the lists
m_widgets.clear();
clear();
// The following prevents the bar from changing size when it has no real buttons.
......
......@@ -25,6 +25,8 @@
#ifndef WQTTOOLBAR_H
#define WQTTOOLBAR_H
#include <list>
#include <QtGui/QToolBar>
#include "guiElements/WQtPushButton.h"
......@@ -55,12 +57,27 @@ public:
*/
WQtPushButton* addPushButton( QString name, QIcon icon, QString label = 0 );
/**
* Add a widget to the toolbar. This also stores the reference and removes it if clearButtons is called.
*
* \param widget the widget to add
*
* \return the corresponding action object
*/
QAction* addWidget( QWidget* widget );
/**
* Removes all buttons,
*/
void clearButtons();
protected:
/**
* The list of widgets in this toolbar.
*/
std::list< QWidget* > m_widgets;
private:
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment