Solved Change the spacing between the close button and the border
-
How to increase the spacing between the close button and the border of the tab?
I'm using this example: https://gist.github.com/espdev/4f1565b18497a42d317cdf2531b7ef05
But the close button is too close to the border of the tab for what I want to do, so I was wondering if it's possible to increase the spacing.
-
@Mr-Gisa
Dunno, but have you triedQTabBar::tab:right
withmargin-right
orpadding-right
? -
@JonB said in Change the spacing between the close button and the border:
TabBar::tab:right
It doesn't work, unfortunately
-
Anyone to help me with that?
-
@Mr-Gisa said in Change the spacing between the close button and the border:
Anyone to help me with that?
This is apparently caused by the
QTabBar::tab:top
section of the stylesheet, which is really the only one relevant to your example: apparently,tab:right
(and all the other orientations) does nothing because theright
in there seems to refer to the tab location (at the top/bottom/left/right of the widget; in Qt Creator these are referred toNorth/South/West/East
in thetabPosition
property).If you remove the
QTabBar::tab:top
section altogether you get the original layout:The
QTabBar::tab:top
section as defined in the example css file, gives the small spacing you are unsatisfied with.This can be reproduced by the following minimal stylesheet:
QString style = "\ QTabBar::tab:top {\ margin-right: -1px;\ padding: 5px 10px 5px 10px;\ }\ "; ui->tabWidget->setTabsClosable(true); ui->tabWidget->setStyleSheet(style);
The result is:
If instead, I use:
QString style = "\ QTabBar::tab:top {\ margin-right: -10px;\ margin-left: 10px;\ padding: 5px 20px 5px 20px;\ }\ QTabBar::tab:top:first {\ margin-left: 0px;\ }\ ";
The result is like:
So, playing with the settings in
QTabBar::tab:top
in addition to overriding certain of those settings forQTabBar::tab:top:first
and/orQTabBar::tab:top:last
(the first and last tabs), you can change the layout somewhat. -
Thank you very much. ♥