You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Friday, November 25th 2011, 5:31am

How to set color for every value in array????

Hi All,
I am developing an application in which i am declaring an array and get the parse value for it. In which i have to set different colors for every individual values,

Here is the lines of code:

for(int i=0 ; i<name.count(); i++)
QString Name = name;
QString Tips = tips[i];
QString City = city[i];
QString Time = time[i];

strList << Name + "\n" + City + "\n" + Tips + "\n" + Time;
ui->listWidgetmyprofile->addItems( strList );

I want to set individual colors for name,city,tips and time.
Is there any coding or properties that is to be set for that??

Thanks in advance and Regards,


Friday, November 25th 2011, 7:46am

Instead of QListWidget, you can use QTableWidget for your requirement.


Friday, November 25th 2011, 8:58am

Hi Satheesh,
I think you have misunderstood my question!!
I need to change the color for every value in the list item ..

Thanks in advance and Regards,


Friday, November 25th 2011, 8:19pm

each item in a qlistwidget is a - look at (set)foreground and (set)background.

Hope that is useful
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.