[Qt-interest] palette behaving in a strange manner.
Pritam Ghanghas
pritam_ghanghas at infosys.com
Mon Mar 21 09:20:49 CET 2011
Hi,
Thank you.
It works. I figured out the problem with old approach also.
Cleanlooks style was polishing my palette.
--
Thanks,
Pritam
On Fri, 2011-03-18 at 22:51 +0530, sarvesh saran wrote:
> Hi,
>
>
> set the palette to the list view not the application
>
>
> view.setPalette(pal); instead of app.setPalette(pal).
>
>
> it should work now.
>
>
> thanks,
> Sarvesh
>
>
> On Fri, Mar 18, 2011 at 9:27 PM, Pritam Ghanghas
> <pritam_ghanghas at infosys.com> wrote:
> Hi
>
> I am trying to set black color for QPalette::HighlightedText.
> and
> setting a gradient for QPalette::Highlight. As soon as I set
> black for
> HighlightedText, the Highlight gradient is drawn as black in
> listview.
>
> The behaviour is correct only for a few color values of
> HighligtedText.
>
> Here is a self contained example:
>
> #include <QtGui>
>
> int main(int argc, char **argv)
> {
> QApplication app(argc, argv);
>
> QPalette pal = app.palette();
>
> pal.setCurrentColorGroup(QPalette::Normal);
> QLinearGradient hiGradient(0.5, 0, 0.5, 1);
>
> hiGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
> hiGradient.setColorAt(0, QColor("#36d3ff"));
> hiGradient.setColorAt(1, QColor("#048dad"));
> pal.setBrush(QPalette::Highlight, QBrush(hiGradient));
> pal.setColor(QPalette::HighlightedText, Qt::black);
>
> app.setPalette(pal);
>
> app.setStyle(new QCleanlooksStyle);
>
> QStringList stringList;
> stringList<<"a"<<"b"<<"c";
>
> QStringListModel model(stringList);
>
> QListView view;
> view.setModel(&model);
> view.show();
>
> return app.exec();
> }
>
> change the HighlightedText color to Qt::white or yellow it
> will work
> fine. Change it to red or black it wont. There are other
> colors also for
> which it works or doesn't work. I am unable to understand how
> it is
> deciding? I tried manually getting the highlight brush and its
> right.
> So there is no corruption in palette.
>
>
> --
> Thanks,
> Pritam
>
>
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION
> intended solely
> for the use of the addressee(s). If you are not the intended
> recipient, please
> notify the sender by e-mail and delete the original message.
> Further, you are not
> to copy, disclose, or distribute this e-mail or its contents
> to any other person and
> any such actions are unlawful. This e-mail may contain
> viruses. Infosys has taken
> every reasonable precaution to minimize this risk, but is not
> liable for any damage
> you may sustain as a result of any virus in this e-mail. You
> should carry out your
> own virus checks before opening the e-mail or attachment.
> Infosys reserves the
> right to monitor and review the content of all messages sent
> to or from this e-mail
> address. Messages sent to or from this e-mail address may be
> stored on the
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list