I would like to be able to change the background colour (even animate the background colour) of a new item in a ListView when it's added to the model.
In particular, if a new item is added to the model, I would like it's background colour to be different (the highlight colour) for 5 seconds and then go back to the normal colour. If the highlight colour could fade back to the normal colour, that would be a bonus.
It would be nice if the colours were dictated by the qss, i.e. not hardcoded.
I imagined subclassing QStyledItemDelegate with an overidden paint function to draw the background (straightforward). Here is a decent read on QStyledItemDelegate.
The subclass could have a QTimer (started in the constructor) so that it could decide between painting the background the highlight colour or the normal colour. This only works if a QStyledItemDelegate is created for each cell and I can't work out from the documentation if that is the case. Is there only one instance of the delegate per view or is there one instance per (visible) index?
This article suggests that there is only one instance of a delegate for multiple similar views, which would mean that the idea of a timer would not work.
Has anyone got any ideas on how to do this?
Bookmarks