PDA

View Full Version : QTreeWidgetItem one icon + one icon button



Alundra
20th November 2014, 16:51
Hi,
I have a QTreeWidget with each element has an icon.
I have an option to set visible or not the data each element of tree widget item has.
The goal is to have the visible button then the icon then the name.
I tried to add a column and set a widget using QToolButton but I got problem :
http://zupimages.net/up/14/47/axtl.png
The eye icon is the visible button.
How achieve that correctly ?
Thanks for the help

StrikeByte
21st November 2014, 11:29
I don't know if it is possible with a QTreeWidget (i only use QTreeView with a self made TreeModel)

If you use a QTreeView with a self made model you can attach a QStyledItemDelegate to the view that adds a button in a cell

If you don't want to make a column in your model just for a view item you can attach a modified proxymodel that adds a virtual column just for the button (I did this for a table view http://www.qtcentre.org/threads/60783-QTableView-add-a-remove-button-to-each-row)