tags:

views:

180

answers:

2

Hello,

I would like to ask if anyone knows how to display 2 QToolBars in two lines, one on top of the other? I found the class QStyleOptionToolBar, but I don't know how to use it...

It is easy to drag one toolbar with the mouse to be placed below the other, so I think there must be a way how this can be done from the source code as well...

Any hint would be appreciated!

Claus

A: 

I think that when you add the 2 toolbar's if you place them in the same area, they'll stack automatically:

QMainWindow *mainWin = get_main(); // however you get it
mainWin->addToolBar(Qt::TopToolBarArea, new QToolBar);
mainWin->addToolBar(Qt::TopToolBarArea, new QToolBar);

This should produce 2 toolbars, both at the top.

Evan Teran
Thank you! I already tried that and it places the two toolbars in one line, but I would like to display the two toolbars in two lines at the top, one below the other. Even if the second toolbar is so large that it does not fit to the width of the mainWin anymore, it is not pushed automatically to a second line, but it is cut and not displayed completely. The documentation of Qt is not clear how to set a toolbar explicitly to the second line, the only hint I found is the QStyleOptionToolBar where are options to place the toolbar, but I do not understand how to use this class...
Bitjuggler
A: 

Try calling QMainWindow::addToolBarBreak(Qt::ToolBarArea) in between adding the two tool bars.

Thank you very much, that's it! I thought I had tried it before, but obviously not... I must have missed it in the QMainWindow documentation... too much late night programming I guess...
Bitjuggler