Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Different editor widgets in QStyledItemDelegate
abstracted8 last edited by
I'm attempting to create a "property editor" type widget analogous to the one in the Qt Designer.
The issue I am facing is how to handle the creation of different editor widgets in the "value" column, depending on the expected input type. I.e.
QDoubleSpinBoxfor decimal input,
QComboBoxfor selection from a list, etc.
I began trying to implement this capability through subclassing
QStyledItemDelegate.createEditor()) and setting the delegate in my
QTreeView. I can find plenty of examples for this procedure when setting the same widget for an entire column. However, I cannot seem to extrapolate from these examples to set widgets in the "value" column depending on the data in the "property column".
I'll try to graphically show below what I want.
Hopefully someone can point me in the right direction, thanks.
In the createEditor function you should query the type of what you are going to show and based on that return the corresponding widget.
Hope it helps