[Qt-interest] color of marked items of QListWidget
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Mon Jun 15 16:34:15 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.
------------------
Just return the Qt::BackgroundColorRole role based on the check state in
your model..
Scott
More information about the Qt-interest-old
mailing list