[PyKDE] Colour a cell in QTableView (PyQt4)

Andreas Pakulat apaku at gmx.de
Thu Sep 21 16:57:55 BST 2006


On 21.09.06 03:27:04, Chris Dunscombe wrote:
> I'm trying to set the colour of cell in a QTableView, not all cells the same colour. I'm using a
> model with a delegate. I've looked at the docs and googled around and can't work out any
> reasonable way to do it. In PyQt3 it was fairly easy as I just sub-classed QTable and
> re-implemented paintCell.

It's easy with Qt4 too, in your model return the proper color if role ==
Qt.BackgroundColorRole and the index is the one you want the color
changed for. Of course if your custom delegate paints the cells, you
need to ask the model for the background role data in the painting
function. Look at the QItemDelegate's painting function to get an idea.

Andreas

-- 
Your goose is cooked.
(Your current chick is burned up too!)




More information about the PyQt mailing list