[Qt-interest] Style sheet selector for QTreeView::item based on item role

Andre Somers andre at familiesomers.nl
Fri May 28 10:06:07 CEST 2010


On 27-5-2010 19:42, Volker wrote:
> Hi everyone.
>
> Is there a way to define a style-rule for a item based on a ItemDataRole?
>
> Im looking for s.t. like a style rule selector which selects items based on
> anything which can be application controlled.
>
>
> What i'm trying to archive is to give particular items a different look in a
> QTreeView depending on item properties expressed by data()+ItemDataRole.
> I know that that this can be done by using e.g. BackgroundRole or even by
> subclassing ItemDelegate. But i like to stick to style sheets.
>
>    
No, there is not, but I think the idea is very valid. I came up with it 
myself just two days ago ;-) (see topic "Alignment in QTableView"). I 
think it should be possible to apply a style to view items without 
having to resort to subclassing. Unfortunately, that is not possible 
yet, but perhaps it could be implemented in the form of a delegate. I'm 
doing some research into that.

André




More information about the Qt-interest-old mailing list