Is it possible to put input widgets inside a tree widget?
-
wrote on 11 Jul 2017, 10:47 last edited by
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?
-
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
wrote on 11 Jul 2017, 12:17 last edited by@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?
wrote on 11 Jul 2017, 12:58 last edited by@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?
wrote on 11 Jul 2017, 14:22 last edited byIt's not on top but a replacement. Your solution works when you have just a few elements in the tree, try to make it ~1000 lines and then scroll down, you'll notice the setItemWIdget solution is too inefficient
2/7