[Qt-interest] ***SPAM*** Re: How to set the color to listview item names

Ramesh ramesh.bs at robosoftin.com
Wed Jun 2 11:02:32 CEST 2010


Hi andre,

Thanks for your answer..

 

I tried with deligate methods, I am able to draw colored text with deligate
methods.

But I just wanted to do the same with out deligate but I guess its
unfortunate..

 

Any way ill go for deligate only.

 

Thanks

 

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Andre Somers
Sent: Wednesday, June 02, 2010 12:47 PM
To: qt-interest at trolltech.com
Subject: ***SPAM*** Re: [Qt-interest] How to set the color to listview item
names

 

On 2-6-2010 8:09, Ramesh wrote: 

Hi,

 

I am interested in placing the different color to item names in listview.

How to do color changing to items in listview?.

 

For example I have two items in listview, by default the color will be
black, but I want it to be blue.

How can I do that?

 

Thanks in advance

 

If you want to color the whole item, you can do that using the
Qt::ForegroundRole to return the right color from the models data() method.
If you don't want to modify the model, you can either use a proxy model in
between the view and the model, or use a QItemDelegate subclass.

If you want to color only part of the text in the item, you're talking about
rich text. That is quite a bit more complex and requires custom delegates
unfortunately. I wrote such a rich text delegate, and I am working on a
delegate on top of that to enable the use of style sheets to style items.
That should make this kind of thing very easy to do (a two-liner), but it is
not ready yet.

André





-----------------------------------------------
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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100602/696cfa95/attachment.html 


More information about the Qt-interest-old mailing list