October 28, 2011

Leon Leon
Ant Farmer
505 posts

[SOLVED] How can i set the background color of listwidget item using rgb values?

 

I want to set the background of my listwidget item.
I don’t want a simple blue so i don’t want this one:

  1.         item->setBackgroundColor("blue");

What i want is the rgb color: 170,170,255.
How can i set the color to this rgb?

4 replies

October 28, 2011

koahnig koahnig
Gene Splicer
2906 posts

You can use a QColor value.
E.g. through http://doc.qt.nokia.com/4.7/qcolor.html#setRgb [doc.qt.nokia.com]

October 28, 2011

Leon Leon
Ant Farmer
505 posts

i had read this thread..

  1.         item->setBackgroundColor(QColor::setRgb ( 170, 170, 255 ));

won’t work.
error: cannot call member function ‘void QColor::setRgb(int, int, int, int)’ without object

October 28, 2011

Andre Andre
Robot Herder
6417 posts

Of course you can not. setRgb is not a static method, after all. Use fromRgb if you do not want to use a QColor object instance that you can manipulate.
This is really basic stuff, and very easy to find in the documentation file that you were already refered to. Please do a bit of digging yourself before asking.

October 28, 2011

Leon Leon
Ant Farmer
505 posts

Haven’t seen this function Andre. All fine now.
Thanks )

 
  ‹‹ QTabWidget: different close image for selected Tab      specify column ordering in qsqltablemodel (was: problem moving columns of a QTableView) ››

You must log in to post a reply. Not a member yet? Register here!