How do I make qtreewidget header transparent? - qt

I want the treewidget header to look as if it's a label, so, I guess, I have to make it transparent? How do I do it?
I tried treeWidget->setStyleSheet("QTreeWidget::header {background-color: transparent}"); but it doesn't work.

The header is not a subcontrol of an itemview, thus QTreeWidget::header will not work. The header rather is a children widget of the view.
That means you could access the header via stylesheets with QTreeWidget QHeaderView {/*style here*/ }
For the background color of a header view you can check out the official Qt example.
In your case as you are setting the stylesheet directly to the view you can omit the parent so the following will do what you asked for:
treeWidget->setStyleSheet("QHeaderView::section { background-color: transparent; }");

In order to set the headers transparent, you have to add the following to the widget stylesheet:
QAbstractItemView QHeaderView {
show-decoration-selected: 0;
background: transparent;
}
QAbstractItemView::section QHeaderView::section {
show-decoration-selected: 0;
background: transparent;
}

Related

Set background color to trasparent CSS

I am trying to set the background color to transparent for this page:
.page-id-714 .container-fluid {
background-color: transparent;
}
But I do not seem to be able to address the correct class or item. Can anyone point me in the right direction?
You are setting it on the wrong class. You need to set it on
.top-stripe {
/* Current, it's set to background-color: #fbfbfb; */
background-color: transparent;
}
Make sure you declare the above after the selector which I've shared below, else you need to make your selector more specific, or you need to use !important which I would not recommend, or better, you remove top-stripe from that declaration altogether.
Here's the declaration on your webpage..
Try this:
.top-stripe {
background-color: transparent!important;
}

QPushbutton How to remove the color created by setDefault(True)

I'm currently try to custom my QPushButton in Qt (PyQt in fact). So I set StyleSheet to do it.
But the problem is that I need to set this button to Default by setDefault to True.
And if I do that, I've a sort of color drool over ... how can I get rid of it?
Here is an example:
button = QPushButton('login')
button.setDefault(True)
button.setObjectName('login')
button.setStyleSheet(
"""
QPushButton#login {
background-color: #4caf50;
color: white;
border: none;
}
QPushButton:pressed#login {
background-color: #59b75c;
}
"""
)
Button appears green, but text is not fully white... I've try to set StyleSheet on QPushButton:default But it does not change anything at all
I can see you have a small error in your code. you gave us
QPushButton:pressed#login {
background-color: #59b75c;
}
but this does not work.
The correct way to do it is
QPushButton#login:pressed {
background-color: #59b75c;
}
also, be sure that after the '#' you use the objectName of the pushButton and not the text of the button.
Here is a link with some styleSheet examples
After long searches on the internet, I finally found how to do. I've to set outline to none to remove it.
QPushButton#login {
background-color: #4caf50;
color: white;
outline: none;
}
Then slobbery color disappear.

FullCalendar change border color not changing

Hi I have this current CSS for fullCalendar (v 1.6.4):
.full-calendar .fc-content .fc-event-container .fc-event {
background: #ef6262!important;
border-color: #eb3d3d!important;
color: #fff!important;
border-radius: 0;
}
When I add a new Class to an event (based on some programming calculations) I do this:
event.className = 'paused-event';
calendar.fullCalendar('updateEvent', event);
My paused-event CSS is this:
.paused-event,
.paused-event div,
.paused-event span {
background: #71CCBF;
border-color: #65B7AB;
}
The background color changes correctly, the border stays the same as the default CSS.
Expectancy:
The event color AND border should change when the paused-event class is present.
The !importants are overriding the latest class properties. You could try to add !important to .paused-event properties as well, but the best would be to avoid any !importants and simply override by impacting with a deeper selector (although it's weird the background does change considering the important):
.class1 vs div.class1.class2 (deeper one)
Anyways, if you simply need to solve that and fast you can try:
.paused-event,
.paused-event div,
.paused-event span {
background: #71CCBF;
border-color: #65B7AB !important;
}

QT Style QPushButton differently whether has Icon or not?

Is it possible to style QPushButtons separately from a qss stylesheet whether it has an icon applied or not?
Something like:
QPushButton[hasIcon="true"] {
background-color: green;
}
QPushButton[hasIcon="false"] {
background-color: red;
}
Thank you!

Styling QTabWidget background with CSS

I wish to set a custom background color for active QTabWidget tab. Unfortunately, I can't figure out the desired selector.
On Linux the following hack works:
QTabWidget::tab > QWidget > QWidget {
background: #fff;
}
But on Windows I have to use one more QWidget:
QTabWidget::tab > QWidget > QWidget > QWidget {
background: #fff;
}
Is there a "real" solution?
You have to use QTabBar and not QTabWidget. The selectors you should use are the following:
// Control the tab-bar with respect to the QTabWidget
QTabWidget::tab-bar {
left: 5px;
}
// Control the look of the tab in general
QTabBar::tab {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
// Control the look of the tab when it is selected
QTabBar::tab:selected
{
// Add css parameters
}
// Control the look of the tab when hovering over it
QTabBar::tab:hover
{
// Add css parameters
}
// Control the look of the tab when it is not selected
QTabBar::tab:!selected
{
// Add css parameters
}

Resources