Unsolved how can i add a button in the 1st column in QTreeWidget?
-
how can i add a button in the 1st column in QTreeWidget?
what i want is like this pic below, and bulb before the text is checkable and be be toggled.
i tried to use multi-colum, when i add button at the cloumns after 1st column, it's OK.
however, when i added the button as the 1st column, there is a problem, when the child and grandchild is expanded the 1st colum which only have a button become very wide...and there is often much blank space before the text of the 2nd column(how can i make the 2nd column like the pic below which is not Aliagned? and go after the 1st button column?)
http://help.autodesk.com/cloudhelp/2015/ENU/3DSMax/images/GUID-5DCC0C7F-6DF0-4B16-BC9E-9F614A62E2F5.png
thank you! -
-
@Ratzz thank you. but i think that's not enough.
because
i tried to use multi-colum, when i add button at the cloumns after 1st column, it's OK.
however, when i added the button as the 1st column, there is a problem, when the child and grandchild is expanded the 1st colum which only have a button become very wide...and there is often much blank space before the text of the 2nd column(how can i make the 2nd column like the pic below which is not Aliagned? and go after the 1st button column?) -
The solution is definitely using a Delegate. QTreeWidget uses a QTreeView and a QStandardItemModel under the hood. You should separate the Model from the View and apply a delegate to the first column of the view. See http://doc.qt.io/qt-5/model-view-programming.html for more details or chapter 10 of http://www.bogotobogo.com/cplusplus/files/c-gui-programming-with-qt-4-2ndedition.pdf
-
thank you
i did use delegate to edit a QTreeWidgetItem.
howerver, i donnot know how to use delegate to add 2 buttons before the original QTreeWidgetItem and its icon...
and i want to react the signals of the 2 buttons...