Results 1 to 2 of 2

Thread: ToolBars with different height

  1. #1
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default ToolBars with different height

    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 

  2. #2
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ToolBars with different height

    btw if I use simple resize(w,h), it works fine (the neighbour isn't affected) but the result is very temporal.

Similar Threads

  1. Set height of QTableView to fit exact number of rows.
    By Ben.Hines in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2019, 01:49
  2. QTextEdit preferred height
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2007, 02:03
  3. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  4. QTextEdit height using Qt3.3.5
    By vermarajeev in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2006, 08:43
  5. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.