#ifndef TESTTOOLBAR_H
#define TESTTOOLBAR_H
#include <QtGui/QMainWindow>
{
Q_OBJECT
public:
TestToolBar
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~TestToolBar();
public slots:
void changeToolBar2height();
private:
};
#endif // TESTTOOLBAR_H
#ifndef TESTTOOLBAR_H
#define TESTTOOLBAR_H
#include <QtGui/QMainWindow>
class TestToolBar : public QMainWindow
{
Q_OBJECT
public:
TestToolBar(QWidget *parent = 0, Qt::WFlags flags = 0);
~TestToolBar();
public slots:
void changeToolBar2height();
private:
QToolBar* ToolBar1,*ToolBar2;
};
#endif // TESTTOOLBAR_H
To copy to clipboard, switch view to plain text mode
testtoolbar.cpp
#include <QtGui>
#include "testtoolbar.h"
TestToolBar
::TestToolBar(QWidget *parent, Qt
::WFlags flags
){
ToolBar1 = addToolBar("ToolBar1");
ToolBar1->addAction(newAct);
ToolBar1->addAction(saveAct);
ToolBar1->addAction(exitAct);
ToolBar2 = addToolBar("ToolBar2");
ToolBar2->addAction(copyAct);
ToolBar2->addAction(cutAct);
ToolBar2->addAction(pasteAct);
connect(newAct,SIGNAL(triggered()),this,SLOT(changeToolBar2height()));
}
TestToolBar::~TestToolBar()
{
}
void TestToolBar::changeToolBar2height()
{
ToolBar1->setSizePolicy(pol);//didn't help
ToolBar2->setMinimumHeight(70);
}
#include <QtGui>
#include "testtoolbar.h"
TestToolBar::TestToolBar(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
QAction* newAct = new QAction(QIcon(":/Resources/new.png"), tr("&New"),this);
QAction* saveAct = new QAction(QIcon(":/Resources/save.png"), tr("&Save"),this);
QAction* exitAct = new QAction(QIcon(":/Resources/exit.png"), tr("&Exit"),this);
QAction* copyAct = new QAction(QIcon(":/Resources/copy.png"), tr("&Copy"),this);
QAction* cutAct = new QAction(QIcon(":/Resources/cut.png"), tr("C&ut"),this);
QAction* pasteAct = new QAction(QIcon(":/Resources/paste.png"), tr("&Paste"),this);
ToolBar1 = addToolBar("ToolBar1");
ToolBar1->addAction(newAct);
ToolBar1->addAction(saveAct);
ToolBar1->addAction(exitAct);
ToolBar2 = addToolBar("ToolBar2");
ToolBar2->addAction(copyAct);
ToolBar2->addAction(cutAct);
ToolBar2->addAction(pasteAct);
connect(newAct,SIGNAL(triggered()),this,SLOT(changeToolBar2height()));
}
TestToolBar::~TestToolBar()
{
}
void TestToolBar::changeToolBar2height()
{
QSizePolicy pol (QSizePolicy::Fixed,QSizePolicy::Fixed);
ToolBar1->setSizePolicy(pol);//didn't help
ToolBar2->setMinimumHeight(70);
}
To copy to clipboard, switch view to plain text mode
Bookmarks