How to color QListWidgetItem
-
hi..
how can we give colors to QListWidgetItem
This is the code I have..
Suppose ,i Want to give green to the QListWidgetItem,how can I do it..
@QListWidgetItem *x=new QListWidgetItem(name,ui->listWidget);
ui->listWidget->addItem(name);
ui->listWidget->show();
@Thanks in advance..
-
It's very simple:
@
QListWidgetItem* pItem =new QListWidgetItem("my text to display");
pItem->setForeground(Qt::red); // sets red text
pItem->setBackground(Qt::green); // sets green background
ui->listWidget->addItem(pItem);
ui->listWidget->show();
@ -
gerolf thanks man..!!
-
Hi
And what if I need to color only part of QListWidgetItem ?
"ABRACADABRA" - whole text in QListWidgetItem
I want to color only "CAD" in red .Thanks.
-
Have a look at this "forum thread":http://developer.qt.nokia.com/forums/viewthread/3314/, it's the same problem.