Reputation: 2250
I ordered my toolbars in the top area in two lines, something like
MyMainWindow::init()
{
addToolBar(Qt::TopToolBarArea, m_toolbar_1);
addToolBar(Qt::TopToolBarArea, m_toolbar_2);
addToolBarBreak(Qt::TopToolBarArea);
addToolBar(Qt::TopToolBarArea, m_toolbar_3);
addToolBar(Qt::TopToolBarArea, m_toolbar_4);
addToolBar(Qt::TopToolBarArea, m_toolbar_5);
}
leading to a results similar to this example using Qt Designer.
As you can see the top tool bars are layed out in two lines.
Now it is very common that the toolbars in the second line (that is m_toolbar_3
, m_toolbar_4
and m_toolbar_5
) get hidden.
This causes the whole second line to disappear, as can be seen in the following screenshot.
I want the second toolbar line to be always shown, no matter if there are visible toolbars in it or not.
This is to avoid visual noise of constantly appearing/disappearing tool bars. The visual noise is especially recognisable in the central widget (where "Form ..." is placed), which is either moved up or down.
Is there a way to do that?
Upvotes: 0
Views: 1059
Reputation: 2084
If it is ok that toolbars stay on the same spot no matter what you could simply set them to non-movable. QToolBar::setMovable
to false.
Upvotes: 0
Reputation: 526
This may not be the best solution ever, but it should work.
QToolBar
has a visibilityChanged signal.
You could connect that to a slot, for example :
connect(m_toolbar, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool)))
Where :
onVisibilityChanged(bool visible)
{
if(false == visible)
{
m_toolbar.setVisible(true);
}
}
Upvotes: 0