[Qt-interest] QTreeView::setStyleSheet using standard branch images

Florian Turck mail at florianturck.de
Mon Dec 14 15:44:09 CET 2009


Hi everybody,

I want to change the style of the items in a QTreeView. Currently I am
using this code to change the font and background color for disabled item:

treeView->setStyleSheet("QTreeView::item:disabled{"
			"color:grey;"	
			"background-color: white;}"
			"QTreeView::branch{"
			"background: white;}"); [1]

This works except that the standard images for the branches (the little
arrows) are not displayed any more. I know I can set the images like this:

treeView->setStyleSheet("QTreeView::branch:has-children:!has-siblings:closed,"
			"QTreeView::branch:closed:has-children:has-siblings{"
			"border-image: none;"
			"image: url(branch-closed.png);}"
			"QTreeView::branch:open:has-children:!has-siblings,"
			"QTreeView::branch:open:has-children:has-siblings{"
			"border-image: none;"
			"image: url(branch-open.png);}"); [2]

Is there a way accessing the standard icons in the code above ([2]) that
are used in QTreeView´s standard style. Or is it possible to define
somewhere that beside the style properties changed in [1] the default
style properties are used.

I want to avoid adding images to the resource system that are already
available somewhere in the depth of Qt.

Thanks

Florian



More information about the Qt-interest-old mailing list