Is it possible to put input widgets inside a tree widget?
-
or is that only to organize lists?
I want to put textboxes into each node of the tree but have the textboxes disappear when I fold together the tree. How can this be done?
@jonasqt Sounds like you need http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget
-
@jonasqt Sounds like you need http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget
@jsulm Not sure I agree. here it's just about the delegate and the default delegate for ext is QTextEdit (which is what I guess you mean by "textboxes") so you really have to do nothing else than setting the edit QTreeWidget edit triggers http://doc.qt.io/qt-5/qabstractitemview.html#editTriggers-prop
-
@jonasqt Sounds like you need http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget
-
@jsulm the documentation says this only applies to static content. If I am waiting for the user to input a value or alter a combobox, would that be considered dynamic or static content?
@jonasqt said in Is it possible to put input widgets inside a tree widget?:
If I am waiting for the user to input a value or alter a combobox
Then what you need is a custom delegate. see http://doc.qt.io/qt-5/model-view-programming.html#delegate-classes and http://doc.qt.io/qt-5/qstyleditemdelegate.html
Since you just need to determine the editor then you can probably just set an editor factory http://doc.qt.io/qt-5/qitemeditorfactory.html on a default delegate
-
@jonasqt said in Is it possible to put input widgets inside a tree widget?:
If I am waiting for the user to input a value or alter a combobox
Then what you need is a custom delegate. see http://doc.qt.io/qt-5/model-view-programming.html#delegate-classes and http://doc.qt.io/qt-5/qstyleditemdelegate.html
Since you just need to determine the editor then you can probably just set an editor factory http://doc.qt.io/qt-5/qitemeditorfactory.html on a default delegate
-
@VRonin I've just done it using setItemWIdget() of the TreeWidget and it's running and the user can enter something into the QTextEdit box.
Why do I still need a custom delegate?