[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Change background color of section in QHeaderView
From:       "Kamp, Peter van der (IMARES)" <peter.vanderkamp () wur ! nl>
Date:       2012-01-31 15:57:46
Message-ID: B451F396CD230E468613575D48F2EF070EA197E5D7 () scomp0537 ! wurnet ! nl
[Download RAW message or body]

Hello,

I have a QTableView with headers. The headers need a different background-c=
olor , depending if the items are set to editable. This can be toggled for =
the entire column by clicking the header. If the items are editable, the he=
ader must have a green background, otherwise red. I try to implement it usi=
ng stylesheets (using ::section:checked). The header changed color, but whe=
n I go to the next column (pressing right arrow) the background of the head=
er in that column changes as well. And that's not what I want. I used setHe=
aderData as well, but that doesn't seem to do anything. What I want is:
Click the header of a certain column once: background of header turns red
Click the header again, background of header turns green.
Other headers must remain the same unless they are clicked too.

What's the best way to solve this problem?

Thanks,

Peter

[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type \
content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 \
(filtered medium)"><style><!-- /* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Verdana","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Hello,<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>I \
have a QTableView with headers. The headers need a different background-color , \
depending if the items are set to editable. This can be toggled for the entire column \
by clicking the header. If the items are editable, the header must have a green \
background, otherwise red. I try to implement it using stylesheets (using \
::section:checked). The header changed color, but when I go to the next column \
(pressing right arrow) the background of the header in that column changes as well. \
And that&#8217;s not what I want. I used setHeaderData as well, but that \
doesn&#8217;t seem to do anything. What I want is:<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Click the header of a \
certain column once: background of header turns red<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Click the header again, \
background of header turns green.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Other headers must remain \
the same unless they are clicked too.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>What&#8217;s the best way \
to solve this problem?<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Thanks,<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Peter<o:p></o:p></span></p><p \
class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New \
Roman","serif";mso-fareast-language:EN-GB'> \
</span><o:p></o:p></p></div></body></html>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--===============1003200043229469176==--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic