PDA

View Full Version : QToolBar not resizing



vermarajeev
14th July 2007, 09:05
Hi all,
I have a QMainWindow with a vertical ToolBar on the left.
I have several toolButtons on ToolBar. On one of the toolButton
there is a popupmenu, which pops up when I click.

The problem:
The pop up menu inside the toolbutton has many entires with names.
The length of the names are small as well as long.
Now suppose, I have these names in popupmenu:
1)"ABC"
2) "HELLOQTCENTRE"
3) "MG"
4) "SEEYOULATER"
5) "CONSTANTTOUCH"

Now initially I set "ABC" as my popup menuItem. Hence initially
"ABC" is selected.
Then I select "HELLOQTCENTRE", the toolBar is expanded(horizontally), again
I select "MG", the toolbar doesnt shrink back(horizontally). It occupies the
same space as before i.e the space for "HELLOQTCENTRE"...

I tried setting the sizepolicy but still it doesnt work.

I want the ToolBar to get resized depending on popup menuItem selected. Please help
Hope I'm clear.
Thanks

marcel
14th July 2007, 18:33
Try first with QToolBar::layout()->setSizeConstraint(QLayout::MinimumSize), although I doubt it will work.

Another solution is to force a resize after you select a new item.
When you select a new item:


toolbar->resize(toolbar->minimumWidth(), toolbar->sizeHint().height());



Regards