QTreeView items - different stylesheet for root and childs - is it possible?
Hello All,
I'm going to create a contact list for my app with groups and I'm using QTreeView with a model. My question is: Can I stylize the root element with style different from the childs or some other trick(s) to specify different stylesheet for each item.
Thanks in advance for all responses.
Re: QTreeView items - different stylesheet for root and childs - is possible?
Yes, see the ::item sub control
You probably need names or another property to differentiate between the root item and a child item.
Re: QTreeView items - different stylesheet for root and childs - is possible?
Hi tbscope,
I'm currently using ::item, but it sets stylesheet to all items and this is not a solution. Can you explain me what property I should use.
QStandardItem has no setObjectName method, so I can't use it to differentiate the items.
Thanks.
Re: QTreeView items - different stylesheet for root and childs - is possible?
You can set a custom type for example.
And read this:
http://doc.qt.nokia.com/4.7/styleshe...mic-properties
Re: QTreeView items - different stylesheet for root and childs - is possible?
I'm afraid, that QStandardItem has no setProperty() and setObjectName() methods?
Re: QTreeView items - different stylesheet for root and childs - is possible?
Hmm, it's indeed not a qobject.
Well, then you'll need to create your own style.
Try a custom proxy style.
Re: QTreeView items - different stylesheet for root and childs - is possible?
I'm sorry for my ignorance, but what is a custom proxy style? (I've searched thru the forum and couldn't find it, can you post any reference if it exists?)
I'm having the same problem that originated this post.
Re: QTreeView items - different stylesheet for root and childs - is possible?