0

I am trying to create a Qt main window application on Mac, but the height of the title bar of QDockWidget is different from height of QToolbar of central widget.

Is there a way to have same height for both?

cbuchart
  • 10,847
  • 9
  • 53
  • 93
P. Preet
  • 15
  • 6
  • Can you possibly add a screenshot to describe how it looks and how you want it to look? – PRIME Mar 28 '18 at 04:08
  • hello, in the above screenshot, the titlebar on the left side widget is slightly shorter (height) than the toolbar of right hand side widget (in which zoomin zoomout and pan). But i compiled same code on windows, there they have perfectly equal height. So i guess this doesn't have to do with Qt in particular. – P. Preet Mar 28 '18 at 18:35

1 Answers1

0

Be aware that those sizes are style-dependant and may vary between platforms and, obviously, style used.

You can use this answer as a starting point and use QToolBar::setFixedHeight to adequate the size to the style used:

const auto dw_style = dock_widget->style();
const int dw_titlebar_height = dw_style->pixelMetric(QStyle::PM_TitleBarHeight);
const int dw_titlebar_margin = dw_style->pixelMetric(QStyle::PM_DockWidgetTitleMargin);

tool_bar->setFixedHeight(dw_titlebar_height - dw_titlebar_margin);

I don't have a Mac to test, but in Windows 10 it works.

Here the example without changing toolbar's height: before

And here using the proposed tweak: after

Hope it can help you.

cbuchart
  • 10,847
  • 9
  • 53
  • 93