If you do not want to expand the collapse icon (triangle icon), you can use the following code
{
Hide the icon before the root node item (expand the collapse icon)
Ui.treewidget->setrootisdecorated (FALSE);
If you just hide the expand collapse icon for the root point and the child node remains, you only need the above statement
Ui.treewidget->setstylesheet ("qtreeview::branch:has-children:!has-siblings:closed,\
Qtreeview::branch:closed:has-children:has-siblings{border-image:none; image:none;} \
Qtreeview::branch:open:has-children:!has-siblings,\
Qtreeview::branch:open:has-children:has-siblings{border-image:none; image:none;} ");
}
If you want to change the expand collapse icon (triangle icon) to your own icon, you can use the following code
{
Ui.treewidget->setstylesheet ("qtreeview::branch:has-children:!has-siblings:closed,\
Qtreeview::branch:closed:has-children:has-siblings{border-image:none; Image:url (:/QtXmlTest/Resources/image/ Plus.png);} \
Qtreeview::branch:open:has-children:!has-siblings,\
Qtreeview::branch:open:has-children:has-siblings{border-image:none; Image:url (:/QtXmlTest/Resources/image/ minus.png);} ");
}
Change Plus.png and minus.png to their own pictures.
A complete Qtreewidget example, download address: http://download.csdn.net/download/jxbinwd/10044343