How to make the border have specific length in stylesheet
-
Here i have a top border of 2px and i want reduce the length of the border how can i do this ?
here is an idea of how i want
my current stylesheet :
QTabBar::tab:selected
{
background-color: rgb(97, 95, 93);
border-top: 3px solid #ffffff;
} -
Hi,
AFAIK, you can't with stylesheet. You will have to paint that yourself.
-
Hi,
I think I have something for you, which is a trick I found to achieve that as well. I'm not sure I could call it a solution, but I think it might be what you need.
As described in my answer on Stack Overflow — How to get bracket style border for QWidget using stylesheets, you could use
QLinearGradient
:background-color: rgb(255, 255, 255); border: 5px solid qlineargradient(spread: pad,x1:0, y1:0, x2:1, y2:0, stop: 0 green, stop: 0.2 green, stop: 0.21 white, stop: 0.8 white, stop: 0.81 green stop: 1 green); border-left: 5px solid green; border-right: 5px solid green;
Just adjust the stops values and the colors, and see if it works for you.
Important: there needs to be a small fraction separating them to achieve a solid color.
Hope it helps!
-
@Abderrahmene_Rayene
A creative solution! The inventors ofQStyleSheet
would probably have said "doesn't work" - and be surprised.