It is very simple: I want to mimic the change in color of an item being disabled without disabling it.
Having QTableWidgetItem and QStandardItem items, I am using code like this
item->setForeground( enabled ? QApplication::palette().color( QPalette::Text ) : QApplication::palette().color( QPalette::Disabled, QPalette::Text ) );
right now. However, if the user calls QApplication::setPalette( ... ) using a new palette, the item has to be manually refreshed. I would much rather set a ColorGroup and Role, so Qt knows how to refresh. Is it possible to do that?
To be automatic you must overwrite the initStyleOption() method of QStyledItemDelegate and associate the fake enable with a new role: