Search code examples
qticonsqtoolbar

Position of icons in vertical QToolbar when switching between Qt::ToolButtonIconOnly and Qt::ToolButtonTextBesideIcon


When switching between Qt::ToolButtonIconOnly and Qt::ToolButtonTextBesideIcon in a vertical QToolBar, there is a slight shift of the icon to the right when expanding the toolbar:

QToolBar

Is it possible to get steady icons, which do not shift to the right like this?

QToolBar


Solution

  • I found a workaround with the stylesheet QToolBar QToolButton { padding-right: 3px; }. To center the icon when the tabbar is closed, I added some spacing to the left of the icon itself.