Changing color of listView elements?
I would like the possibility to change the color of elements loaded into my ListView through a model.
I've been trying to to this and all I could do is change the element text to bold or italics using some HTML tags like <b></b> but I haven't been able to change the color at will.
Thanks in advance :) .
I guess that you are talking about "QListView":http://qt-project.org/doc/qt-4.8/qlistwidget.html because this topic is posted under the General and Desktop forum. Check the "following tutorial about background color of QWidget":http://qt-project.org/wiki/How_to_Change_the_Background_Color_of_QWidget.
The foreground and background colors are provided by your model.
You should return wanted color in your data(const QModelIndex&, int role) implementation of the model.
To change text color check role parameter for Qt::ForegroundRole and Qt::BackgroundRole for background.
Oh sorry I forgot to mention that I am using QML ListView