I have added several items to the QToolBar using addAction method. Is there a way to control a spacing inside item? I mean spacing between item text (or icon) and item border
Asked
Active
Viewed 3,139 times
2

Mikhail Zimka
- 694
- 1
- 9
- 20
-
You could try [`QWidget::setContentsMargins`](http://doc.qt.io/qt-5/qwidget.html#setContentsMargins). – G.M. Sep 28 '16 at 07:52
-
@G.M. QWidget::contentMargins doesn't affect spacing inside QToolBar's item – Mikhail Zimka Sep 28 '16 at 07:55
1 Answers
4
You can use style sheets. Example:
myToolbar->setStyleSheet("QToolButton { padding-left: 20px; padding-right: 40px; }");

Fabio
- 2,522
- 1
- 15
- 25
-
This works only to increase padding - if I set padding-left: 40px the spacing really grows up. But if I set padding-left: 0px nothing changes - it seems that there is something like minimum padding level. – Mikhail Zimka Sep 28 '16 at 09:29
-
2It seems that you can decrease the space setting a negative padding (I've tried with Qt 5.5, Windows style (Win 10)) – Fabio Sep 28 '16 at 12:17