It sounds to me that what you really need is to pop up a level in the widget hierarchy and use a QTableView (instead of QTableWidget) and derive a model from QAbstractTableModel. In the model's data() method, you have control over all kinds of appearance things. See Qt::ItemDataRole. In trying to implement a delegate that jumps through all these hoops, you are essentially reinventing all of the functionality that QAbstractTableModel / QTableView give you for free.And a second question:
What is better for performance: handling the whole table design (background color, text etc.) directly via QItemDelegate:aint(...) or would it be better to create QTableWidgetItems and set the specific background colors? I mean, setting background colors via delegate would result in updating the background color each time anything happens, but that is not neccessary for me, because I set the background colors once and they are static. On the other hand, I could imagine that the delegate will do that anyway, because, as I know now, it gets the information from the table so it will repaint the backgrounds like the QTableWidgetItems orders it...
So, is there any sense in using QTableWidgetItems when I use a custom delegate anyway?
Bookmarks