[Qt-interest] palette behaving in a strange manner.

kahola g kahola.g at gmail.com
Mon Mar 21 08:59:04 CET 2011


Hi sarvesh,

It works. But what is wrong with old approach. When we set palette on
QAppplication, shouldn't it apply for all widgets. Qt documentation says so
:

"If className is passed, the change applies only to widgets that inherit
className (as reported by QObject::inherits()). If className is left 0, the
change affects all widgets, thus overriding any previously set class
specific palettes."

thanks,
Pritam

On Fri, Mar 18, 2011 at 10:51 PM, sarvesh saran
<aquarian.thunder at gmail.com>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
>>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110321/75bca17e/attachment.html 


More information about the Qt-interest-old mailing list