You can use style sheets for it
OK, I am trying really hard to get this to work. I have copied the QTreeView example from the customization examples page, have copied all of the images they include in that example and have added them to my QRC file. The absolute URL path to the images should be ":/Resources/stylesheet-vline.png" for example, which I know works because I can use it to set a toolbar icon.
I can't get any of the images to appear. I have tried every variation on the URL path: no ":", no ":/", no ":/Resources", but get nowhere. I think the stylesheet is getting processed correctly, because the default icons are gone, too. (Prior to this, I had some extra whitespace in the stylesheet string, and the default icons didn't change when the sheet was loaded).
I have also tried a minimal stylesheet with only the "QTreeView::branch:has-siblings:adjoins-item" clause to see if I could get just one of the icons to show up, but no luck.
Any suggestions? Here is the complete stylesheet QString (without the URL prefixes):
static QString sTreeStyle
= "QTreeView::branch:has-siblings:!adjoins-item {\ border-image: url( stylesheet-vline.png ) 0;\
}\
\
QTreeView::branch:has-siblings:adjoins-item {\
border-image: url( stylesheet-branch-more.png ) 0;\
}\
\
QTreeView::branch:!has-children:!has-siblings:adjoins-item {\
border-image: url( stylesheet-branch-end.png ) 0;\
}\
\
QTreeView::branch:has-children:!has-siblings:closed,\
QTreeView::branch:closed:has-children:has-siblings {\
border-image: none;\
image: url( stylesheet-branch-closed.png );\
}\
\
QTreeView::branch:open:has-children:!has-siblings,\
QTreeView::branch:open:has-children:has-siblings {\
border-image: none;\
image: url( stylesheet-branch-open.png );\
}";
static QString sTreeStyle = "QTreeView::branch:has-siblings:!adjoins-item {\
border-image: url( stylesheet-vline.png ) 0;\
}\
\
QTreeView::branch:has-siblings:adjoins-item {\
border-image: url( stylesheet-branch-more.png ) 0;\
}\
\
QTreeView::branch:!has-children:!has-siblings:adjoins-item {\
border-image: url( stylesheet-branch-end.png ) 0;\
}\
\
QTreeView::branch:has-children:!has-siblings:closed,\
QTreeView::branch:closed:has-children:has-siblings {\
border-image: none;\
image: url( stylesheet-branch-closed.png );\
}\
\
QTreeView::branch:open:has-children:!has-siblings,\
QTreeView::branch:open:has-children:has-siblings {\
border-image: none;\
image: url( stylesheet-branch-open.png );\
}";
To copy to clipboard, switch view to plain text mode
Bookmarks