[Interest] Setting current item text color via stylesheet in QTableView for SelectRows

Reinhardt Behm rbehm at hushmail.com
Wed Aug 8 03:00:32 CEST 2018


On Tuesday 07 August 2018 16:31:42 Patrick Stinson wrote:
> Hello!
> 
> I have a vanilla QTableView with SingleSelection and SelectRows and am
> trying to figure out how to set the text color of the current item for both
> when the row is selected and when it isn’t. This is important so that the
> user knows which cell will be edited when they hit the enter key and so
> they can navigate to a new cell using the arrow keys.
> 
> It seems that the following will do it, but it doesn’t apply when the row is
> selected.
> 
> QTableView::item:focus {
>     color: yellow;
> }
> 
> How can this be done?
> 
> Thanks!
> -Patrick

Here something is used in a similar case

TableViewBase {
	font-size: 18px; font-weight: bold;
	background-color: white;
}
 TableViewBase::item {
	color: black;
	font-size: 18px; font-weight: bold;
	background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 
#f6f7fa, stop: 1 #dadbde);
}
TableViewBase::item:selected {
	color: white;
	background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 
#606060, stop: 1 #000000);
}
-- 
Best Regards

Reinhardt Behm





More information about the Interest mailing list