PDA

View Full Version : Qt table cell coloring



cubesnyc
1st April 2014, 05:34
What would be the best way to manage the coloring (background color and border color/style) of a particular cell? I would like to create the appearance of merged cells.

ChrisW67
1st April 2014, 05:40
A particular cell in a QTableView? QTableView already supports cell spanning (see QTableView::setSpan()), are you sure you need to fake it.

The background colour for a cell comes, by default, from the data the model returns for the Qt::BackgroundRole. It can be manipulated by a delegate attached to the view.

cubesnyc
1st April 2014, 06:13
A particular cell in a QTableView? QTableView already supports cell spanning (see QTableView::setSpan()), are you sure you need to fake it.

The background colour for a cell comes, by default, from the data the model returns for the Qt::BackgroundRole. It can be manipulated by a delegate attached to the view.

Yes, I do not need the actual cells to be merged. I just want to paint a grid rectangle around them to give off that appearance for style purposes. I am familiar with Qt::Background role within the data() function of AbstractTableView but I am not sure how to relate that to the task at hand?