Keeping the same selection color in a TableView whether it's active or not - qt

I'm using QTableView class in my GUI and I would like the selected row to have the same color whether the TableView is active or inactive.
I tried to set this CSS stylesheet to achieve this:
QTableView:!active {
selection-background-color: palette(Highlight);
selection-color: palette(HighlightedText)
}
On Linux, it works just fine, but on Windows 7, when the TableView loses its focus, the text turns black instead of staying white (the background stays blue, so that part is OK). Am I missing something here ?

You also have to style text color, for example just add:
QTableView:!active {
...
selection-color: white;
}

This works well in python
pal = tbl_list.palette()
pal.setColor(QPalette.Inactive, QPalette.Highlight, pal.color(QPalette.Active, QPalette.Highlight))
tbl_list.setPalette(pal)

Related

Is it possible to make existing icon lighter on hover

For example I've QToolButton with custom icon
Can I make this icon lighter on hover using QToolButton:hover qss?
Could you please try below options:
option 1:
Try PaletteRole property type
http://doc.qt.io/qt-5/stylesheet-reference.html#paletterole
As you require for hovering,
QToolButton:hover { color: palette(light); }
option 2:
Create a different image with lighter view Icon.
And set the background when you hover on it.
QToolButton:hover { background: url("LighterView.png") ; }

JavaFx change background color of disabled textarea

I need to use textarea in my program and I also need it to be read-only.
This is part of my main program where I create textArea:
final TextArea ta = new TextArea();
ta.setMaxSize(9*x, 7*x);
ta.setId("textarea");
ta.setTranslateX(x);
ta.setTranslateY(2*x);
ta.setDisable(true);
This is part of my css file:
#textarea {
-fx-font: 13px "Serif";
-fx-background-color: BEIGE;
}
If I delete the row: ta.setDisable(true); Css works like I want it to work. But after I set disable true, it just makes the textarea transparent, which makes the text really hard to read and the background color is not excatly what I want too.
Is there any other way to set text readonly? Or is there a way to use css after disable. I really need it to be TextArea not Label or any other type. Thank you in advance.
If you do not want the user to make changes to the textarea use the setEditable(boolean) method to false. The same method exists for most editable nodes in javafx(Textfield and PasswordField).

QPushButton focus

I have a pushbutton which its background image gets changed regularly according to the packets ui receives from serial. When the user clicks the button, it becomes red with borders.
pb_Jack1Up ->setStyleSheet("QPushButton {border-image: url(:/ArrowKey/Up_Default.jpg); } QPushButton:focus {border-width: 1px;border-style: solid; border-radius: 4px;}");
Now, what I want is to give the button some effects, to make the user understand that the button is clicked. like make the button go inside when clicked, and when user releases the button border shall no longer be set anymore. However, in my case the button border remains. I cannot also set style sheet with pressed and released slots, because the background image depends on what we receive from serial.
Could anyone help me please?
You can use:
QPushButton { ... }
QPushButton:disabled { ... }
QPushButton:pressed { ... }
QPushButton:focus { ... }
QPushButton:hover { ... }
or take a look at this blog entry.
The button keepsfocus after you release the mouse. Thats why it still has the red border.
You can check that if you activate another widget of the form, clicking, or tabbing, red border dissapears.
Try using
QPushButton:pressed
instead of focus

FullCalendar event text colour change

I added className fc-selected to [any selected day] which took care of my background colour changes for that selected cell. Thinking that I was home free and only needed to change color for the text next, I forcefully removed a few locks of hair when, only way later, did I realize that the date events are not even in the date cell but absolutely positioned above and outside of it.
How can I target the DOM of the events for a selected date in the calendar?
PS: Basically the background color for a date cell goes dark red on selection and I need the title text to temporarily change to white.
You can set an event's
textColor: white or #FFF
http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
You can also set eventTextColor while redering event
http://arshaw.com/fullcalendar/docs/event_rendering/eventTextColor/
Actually, I tried many times and any variations of textColor or eventTextColor didn't worked at all. So, I tried changing color attributes manually;
.portlet.calendar .fc-event .fc-time {
color: white;
}
.portlet.calendar .fc-event .fc-title {
color: white;
}
By using simple javascript like this you can also set font-color of fullcalendar;
var colorStyle = document.getElementsByClassName('fc-title');
for (var i=0; i<colorStyle.length; i++) {
colorStyle[i].style.color = 'white';
}

Change the selection color of a QTableWidget

The default is for the selected row to be colored gray if the QTableWidget does not have focus, and orange if it does have focus. I would like to, instead, make the selected row be red whether or not the widget has focus. I tried adding this to the style sheet:
QTableWidget{ selection-background-color: red}
I also tried
QTableWidget:edit-focus{ selection-background-color: red}
and
QTableWidget:focus{ selection-background-color: red}
but none of them seem to turn anything red, it still seems to remain orange if focused and gray if not. What properties do I have to set to make the selected row always the same color, whether or not it has focus?
Thanks,
David
You almost had it. Technically speaking, you're adjusting the selection color of the items within your table widget, so:
QTableWidget::item{ selection-background-color: red}
should do the trick.
Alternatively:
QTableWidget::item{ background-color: blue }
QTableWidget::item:selected{ background-color: red }
background-color will set background color of the items in row and selection-color will set the text color because when the row is selected then if text are present in the row then it might become unreadable due to color so setting proper text color is important.
#d9fffb : light blue
#000000 : black
self.table.setStyleSheet(
"QTableView::item:selected"
"{"
"background-color : #d9fffb;"
"selection-color : #000000;"
"}"
)

Resources