The QAbstractItemModel' data method failed to overwrite background
I have a QTreeView which has a stylesheet applied to items with "QTreeView::item{background-color:#F7F7F7}". The view has a custom model and in the data method, I change the background of some specific cells like this :
Code:
if (index.column() == 3 && role == Qt::BackgroundColorRole)
{
}
But this is not working to overwrite the value set in stylesheet. Is there anyone who can tell me what I miss? Thanks!!!
Re: The QAbstractItemModel' data method failed to overwrite background
Stylesheets seem to override and ignore the formatting data coming from the model. See this thread for some suggestions and details:
https://forum.qt.io/topic/95940/mode...style-sheet/11
Re: The QAbstractItemModel' data method failed to overwrite background
Either just extend the model to return the other color for the other columns or is a QIdentityProxyModel to supply the "fall back" background color for cells for which the original model didn't provide any.
Cheers,
_
Re: The QAbstractItemModel' data method failed to overwrite background
thanks a lot. seems I cannot use stylesheet then.
Thanks a lot. I would try