PDA

View Full Version : How do i change background of QTableView cells



.:saeed:.
9th February 2011, 12:09
Hello
i want to have a filtering system for my big table view that is populated from a database . i have a line edit and i can obtain tableview indexes that contain line edit's text but how do i change the QModelIndexList items' backgrounds ?:(
thanks

srazi
9th February 2011, 15:42
Every item has a widget, just set the background for that.


//'index' is 'QModelIndex' for item
//'table' is 'QTableView *' instance
//'PIXMAP_PATH' is your background image path
QWidget *widget = table->indexWidget( index );
QPalette p( widget->palette());
p.setBrush(QPalette::Base, QBrush(QPixmap(PIXMAP_PATH)) );
widget->setPalette(p);
table->setIndexWidget( index, widget );