[Qt-interest] Query related selection color in Qt

Ramesh ramesh.bs at robosoftin.com
Thu Jun 24 06:45:45 CEST 2010


Ya sure.
Thanks pritam, I will try..
Any way andre suggested to go for stylesheet I will try that..

Thanks & regards,
Ramesh

-----Original Message-----
From: Pritam Ghanghas [mailto:pritam_ghanghas at infosys.com]
Sent: Wednesday, June 23, 2010 7:01 PM
To: Ramesh
Subject: RE: [Qt-interest] Query related selection color in Qt

my problem was different. Not related to option palette. but I think you
can try setting the palette get the applicaton palette, modify it and
set it on this* either in your delegate or view, you will have to see. I
dont remember exactly how the options is initialized inside
initstyleInit.
I had by mistake replied on your personal ID. Though I replied the same
thing on list. Please bring it back to list, others may also give you
solutions and they may be better than this one.

On Wed, 2010-06-23 at 18:50 +0530, Ramesh wrote:
> Can you tell me how did you get rid of this situation.
> This could save lot of calculations which I have to put for drawing text :(.
>
>
> -----Original Message-----
> From: Pritam Ghanghas [mailto:pritam_ghanghas at infosys.com]
> Sent: Wednesday, June 23, 2010 6:44 PM
> To: Ramesh
> Subject: Re: [Qt-interest] Query related selection color in Qt
>
> I am sure somewhere the base class implementation is calling
> initStyleOption(&option, index)
> that is overriding your values. I had faced a similar problem once.
>
>
> On Wed, 2010-06-23 at 18:13 +0530, Ramesh wrote:
> > Hi,
> >
> > I want to highlight the selected item text color in listview, for this
> > I am painting  the text in delegate method.
> >
> > My problem is, if I set the pen to painter and draw the text manually
> > it works, but if the system draw text it doesn't work
> >
> > May I know the reason why it happens like this?
> >
> >
> >
> > Here is the sample code of delegate where my problem is occurring.
> >
> >
> >
> > In this code, I am setting the pen color to painter and passing it to
> > base class to draw, still painter doest draw with the color which I
> > set.
> >
> >
> >
> > const bool sel((option.state & QStyle::State_Selected) ==
> > QStyle::State_Selected);
> >
> > QBrush baseBrush(sel ? option.palette.highlight() :
> > option.palette.base());
> >
> > QBrush textBrush(sel ? option.palette.highlightedText() :
> > option.palette.text());
> >
> >
> >
> > QColor color = textBrush.color();
> >
> > painter->setPen(QColor(0,102,255));
> >
> > QStyledItemDelegate::paint(painter,option,index);
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > -----------------------------------------------
> >
> > Robosoft Technologies - Come home to Technology
> >
> > Disclaimer: This email may contain confidential material. If you were
> > not an intended recipient, please notify the sender and delete all
> > copies. Emails to and from our network may be logged and monitored.
> > This email and its attachments are scanned for virus by our scanners
> > and are believed to be safe. However, no warranty is given that this
> > email is free of malicious content or virus.
> >
> >
>
>
>
> -----------------------------------------------
> Robosoft Technologies - Come home to Technology
>
> Disclaimer: This email may contain confidential material. If you were not an 
> intended recipient, please notify the sender and delete all copies. Emails 
> to and from our network may be logged and monitored. This email and its 
> attachments are scanned for virus by our scanners and are believed to be 
> safe. However, no warranty is given that this email is free of malicious 
> content or virus.



-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.



More information about the Qt-interest-old mailing list