PDA

View Full Version : QAbstractItemView



zgulser
19th August 2009, 07:47
Hi,

I wonder is it possible to give a fixed text color for examle for the 2nd item in a QComboBox? I tried up to;

QAbstractItemView{ color: gray};

but obviously there is no specific item number above as you see, which I exactly want.

Thanks in advance.

caduel
19th August 2009, 08:21
using code you can do that; you could use a proxy model for example

zgulser
19th August 2009, 08:38
Hi again,

Can you be a bit more specific if you don't mind?

numbat
19th August 2009, 12:30
This seems to work:


cb->addItem("Red");
cb->addItem("Gray");
cb->addItem("Green");
cb->setItemData(0, Qt::red, Qt::ForegroundRole);
cb->setItemData(1, Qt::gray, Qt::ForegroundRole);
cb->setItemData(2, Qt::green, Qt::ForegroundRole);
cb->setItemDelegate(new QStyledItemDelegate);