PDA

View Full Version : QListWidget change selected items background color



cic
25th April 2014, 08:59
Hello all,

i have read some documents but the codes there are mostly invalid.



int main(int argc,char ** argv)
{
QApplication app(argc,argv);

QListView* view = new QListView();
QStringListModel* model = new QStringListModel((QString("1;2;3;4;5").split(";")));
QPalette palette;

palette.setColor(QPalette::Highlight,Qt::red);
view->setPalette(palette);
view->setModel(model);

view->setWindowTitle("QListView Selected Item Bg Color");
view->show();

return app.exec();
};


for example the code above is a sample which peole use it to set the background color. I run this sample and the color remains still the same.

10310