[Qt-interest] color of marked items of QListWidget

Ferenc Stelcz ferenc at stelcz.hu
Mon Jun 15 16:16:52 CEST 2009


Serge wrote:
> Hi,
> 
> I need to have different background color of checked and unchecked items 
> of QListWidget. Is it possible to do it using stylesheet? or there is 
> some other method?
> 
> --
> Serge

Hi!

You could iterate over your QListWidget and check each item if it is checked. 
Then if one item is checked you can use the setBackground(const QBrush&) 
method of QListWidgetItem to set its background. Another option is to connect 
the itemChanged(QListWidgetItem* item) of QListWidget to a slot which checks 
if the Qt::CheckStateRole is equal to Qt::Checked on the current item and if 
yes, then sets its background color to the one you specify.

HTH

--
Ferenc Stelcz
Junior Software Engineer

Banyan Technologies LLC.


__________ Information from ESET Smart Security, version of virus signature database 4154 (20090615) __________

The message was checked by ESET Smart Security.

http://www.eset.com





More information about the Qt-interest-old mailing list