I'm currently using stylesheets to theme an application.
Here is the stylesheet I use for QTabWidget:
/*QTabBar et QTabWidget*/
QTabBar::tab {
background: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(73, 73, 74, 255), stop:1 rgba(40, 40, 40, 255));
border: 1px solid rgb(190, 190, 190);
max-height: 0.6em;
min-width: 0.6em;
padding: 5px;
margin-left: -1px;
margin-right: -1px;
}
QTabBar::tab:selected, QTabBar::tab:hover {
background: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(39, 117, 219, 255), stop:1 rgba(107, 171, 249, 255));
}
QTabBar::tab:last {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
margin-right: 0px;
}
QTabBar::tab:first {
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
margin-left: 0px;
}
QTabBar::tab:only-one {
border-radius: 3px;
margin: 0px;
}
With this, when tabPosition is set to North or South, no problem. But with East or West, the TabBar's border is not properly styled.
Do someone know how to style a TabBar with tabPosition set to east/west?
From the Qt stylesheet reference page:
The :top, :left, :right, :bottom pseudo states depending on the
orientation of the tabs.
So, for example, to apply your first css rule to the horizontal QTabBars:
QTabBar::tab:top, QTabBar::tab:bottom {
background: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(73, 73, 74, 255), stop:1 rgba(40, 40, 40, 255));
border: 1px solid rgb(190, 190, 190);
max-height: 0.6em;
min-width: 0.6em;
padding: 5px;
margin-left: -1px;
margin-right: -1px;
}
Related
I can't tell my HR gradient is not taking effect or even displaying.
hr.green {
margin-top: 20px;
margin-bottom: 20px;
border: 1px dashed;
border-left: 0;
border-bottom: 0;
border-right: 0;
border-image: linear-gradient(90deg, rgba(48, 183, 149, 1) 10%, rgba(130, 195, 65, 1) 100%) !important;
border-image-slice: 1;
}
body {
background-color:black;
}
<h1>
TEST
</h1>
<hr class="green">
Did I have a typo somewhere?
I was hoping to see something like this.
add the slice inside the border-image because it will also set the border-image-width which is missing here:
hr.green {
margin-top: 20px;
margin-bottom: 20px;
border: 1px dashed;
border-left: 0;
border-bottom: 0;
border-right: 0;
border-image: linear-gradient(90deg, rgba(48, 183, 149, 1) 10%, rgba(130, 195, 65, 1) 100%) 1;
}
body {
background-color: black;
}
<h1>
TEST
</h1>
<hr class="green">
I have a code:
button {
background: rgb(1, 81, 227);
background: linear-gradient(
90deg,
rgba(1, 81, 227, 1) 35%,
rgba(0, 90, 255, 1) 100%
);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
border-radius: 6px;
}
And a ton of buttons. I want to apply that css code for all buttons except two, with the IDs startAction & endAction.
How do I do that?
button:not(#startAction):not(#endAction)
by #underscore_d
Your startAction and endAction buttons probably share some of those styles.
If so, just keep those shared lines within the generic button declaration and move the other stuff into a new style and then apply that to the rest of the buttons.
Something like...
button {
display: inline-block;
border: none;
color: white;
...
}
.fancybutton {
background: rgb(1, 81, 227);
background: linear-gradient(
90deg,
rgba(1, 81, 227, 1) 35%,
rgba(0, 90, 255, 1) 100%
);
margin: 4px 2px;
...
}
I need to disable :active pseudo selector for some (but not all) buttons. So button stays with exact same styles as it was as user fires onmousedown event.
I've tried to duplicate css styles from default btn to btn:active and it partially works, but some styles got overwritten.
Maybe there is some other options. I'm fine with using some quick and dirty solution for now.
In case someone need the code - posting it below:
.btn-system {
outline: none;
box-sizing: border-box;
height: 21px;
padding: 0px 16px;
font-size: 13px;
border: 1px solid #d5d5d5;
font-weight: 400;
background-color: #fff;
letter-spacing: 0.4px;
border-radius: 4.5px;
border-top-color: rgb(198, 198, 198);
border-bottom-color: rgb(170, 170, 170);
border-left-color: rgb(192, 192, 192);
border-right-color: rgb(192, 192, 192);
}
.btn-system.btn-active:not([disabled]), .btn-system:active {
/*color: #fff;
font-weight: 300;
letter-spacing: 0.8px;
padding: 0px 16px;
border-top-color: rgb(64, 150, 248);
border-bottom-color: rgb(9, 85, 255);
border-left-color: rgb(39, 122, 252);
border-right-color: rgb(39, 122, 252);
background-image: linear-gradient(rgb(94, 168, 249), rgb(14, 117, 255));*/
letter-spacing: 0.8px;
color: #fff;
font-weight: 300;
padding: 0px 17px 1px 16px;
border-top-color: rgb(64, 150, 248);
border-bottom-color: rgb(9, 85, 255);
border-left-color: rgb(39, 122, 252);
border-right-color: rgb(39, 122, 252);
background-image: linear-gradient(rgb(94, 168, 249), rgb(14, 117, 255));
}
.btn-system:active {
border-top-color: rgb(30, 114, 254);
border-bottom-color: rgb(3, 56, 216);
border-left-color: rgb(16, 82, 233);
border-right-color: rgb(17, 82, 227);
background-image: linear-gradient(rgb(64, 140, 253), rgb(11, 93, 224));
}
Give id's to those buttons with which you want to use pseudo selector
Hope this helps
I am using a custom CSS for a Qt5 window, but there is an ugly horizontal line on the selected button that I would like to get rid of it, or customize it.
This is the CSS I'm using right now.
* {
background-color: black;
color: white;
font: 24px;
}
QPushButton:disabled {
background-color: rgb(67, 67, 67);
border-color: rgb(67, 67, 67);
}
QPushButton {
color: black;
background-color: yellow;
border-width: 1px;
border-color: yellow;
border-style: solid;
border-radius: 10px;
min-width: 3em;
min-height: 30px;
padding: 6px;
}
QPushButton:pressed {
background-color: rgb(255, 193, 0);
border-color: rgb(255, 193, 0);
}
QPushButton:hover {
border-color: rgb(255, 193, 0);
}
QPushButton:default {
background-color: rgb(255, 255, 255);
}
I am facing a problem with QScrollArea.
In particular I can not find the right QSS rule for removing the 3px space between QSrollArea QFrame and QScroll.
The space I'd like to remove is the one pointed by the red arrow in the picture. I also added a blue border to the internal QFrame of the QSrollArea, but it seems to end correctly.
The image can be found here: http://i58.tinypic.com/2h71a2c.png
I am using QT 4.8.5 on a SLED 11 SP2 (under GNOME).
My QSS looks like this:
QScrollArea {
background: transparent;
}
QScrollArea > QWidget > QWidget
{
background: transparent;
border: 1px solid black;
margin: 0px 0px 0px 0px;
}
QScrollBar:horizontal
{
border: 1px solid #999999;
background:white;
height:7px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
QScrollBar::handle:horizontal {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop: 0 rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130), stop:1 rgb(32, 47, 130));
min-width: 20px;
}
QScrollBar::add-line:horizontal {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop: 0 rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130), stop:1 rgb(32, 47, 130));
height: 0px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop: 0 rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130), stop:1 rgb(32, 47, 130));
height: 0px;
subcontrol-position: left;
subcontrol-origin: margin;
}
Any Ideas?
Thanks.
Is it imperatively necessary to do it from QSS and QSS only? I think changing the layoutBottomMargin of the scrollAreaWidgetContents(i.e. the widget inside the QScrollArea) will solve the problem.