Search code examples
c++qtqtoolbar

QToolBar - disable margins


When I call setIconSize(QSize(16, 16)) on QToolBar, it leaves margins from all sides, mainly bottom. setContextMargins(0, 0, 0, 0) does not help. Other toolbars I have are set up in the form of main window and look fine, but this one is supposed to be in QDockWidget, so I need to do it programmatically.

Image with comparison:

When I force the height of the toolbar to 16, the icons crop.
How to the other toolbar exactly the same size and padding?


Solution

  • To disable margins:

    layoutThatContainsToolBar->setSpacing(0);