Qt 4.4.0
There are 2 QToolBars in the same area, for example Qt::TopToolBarArea. I want to make one of them higher, so it can include several rows of buttons, but the neighbour adjusts itself, so it has the same height, it looks ugly. How can I make toolbars that are in the same area have different height (if Top or bottom area) or width (if right or left area)?
testtoolbar.h
Qt Code:
  1. #ifndef TESTTOOLBAR_H
  2. #define TESTTOOLBAR_H
  3.  
  4. #include <QtGui/QMainWindow>
  5.  
  6.  
  7. class TestToolBar : public QMainWindow
  8. {
  9. Q_OBJECT
  10.  
  11. public:
  12. TestToolBar(QWidget *parent = 0, Qt::WFlags flags = 0);
  13. ~TestToolBar();
  14. public slots:
  15. void changeToolBar2height();
  16. private:
  17. QToolBar* ToolBar1,*ToolBar2;
  18. };
  19.  
  20. #endif // TESTTOOLBAR_H
To copy to clipboard, switch view to plain text mode 
testtoolbar.cpp
Qt Code:
  1. #include <QtGui>
  2. #include "testtoolbar.h"
  3.  
  4. TestToolBar::TestToolBar(QWidget *parent, Qt::WFlags flags)
  5. : QMainWindow(parent, flags)
  6. {
  7. QAction* newAct = new QAction(QIcon(":/Resources/new.png"), tr("&New"),this);
  8. QAction* saveAct = new QAction(QIcon(":/Resources/save.png"), tr("&Save"),this);
  9. QAction* exitAct = new QAction(QIcon(":/Resources/exit.png"), tr("&Exit"),this);
  10. QAction* copyAct = new QAction(QIcon(":/Resources/copy.png"), tr("&Copy"),this);
  11. QAction* cutAct = new QAction(QIcon(":/Resources/cut.png"), tr("C&ut"),this);
  12. QAction* pasteAct = new QAction(QIcon(":/Resources/paste.png"), tr("&Paste"),this);
  13. ToolBar1 = addToolBar("ToolBar1");
  14. ToolBar1->addAction(newAct);
  15. ToolBar1->addAction(saveAct);
  16. ToolBar1->addAction(exitAct);
  17. ToolBar2 = addToolBar("ToolBar2");
  18. ToolBar2->addAction(copyAct);
  19. ToolBar2->addAction(cutAct);
  20. ToolBar2->addAction(pasteAct);
  21. connect(newAct,SIGNAL(triggered()),this,SLOT(changeToolBar2height()));
  22. }
  23.  
  24. TestToolBar::~TestToolBar()
  25. {
  26.  
  27. }
  28. void TestToolBar::changeToolBar2height()
  29. {
  30.  
  31. QSizePolicy pol (QSizePolicy::Fixed,QSizePolicy::Fixed);
  32. ToolBar1->setSizePolicy(pol);//didn't help
  33. ToolBar2->setMinimumHeight(70);
  34. }
To copy to clipboard, switch view to plain text mode