I need to create a table that will contain multiple types of delegates; spinners, dropdowns, text, checkboxes, etc. Something like a Properties panel in an IDE.
I think that the default delegates will be fine; I don't need anything fancy for presentation. I do need to be able to set the min/max for int values in the spinners as well as other validation on the values. Is there a way to do this without writing my own delegate or creating a new editor for QItemEditorFactory? I'd prefer to keep all business logic in the Model.
I would think this would be a simple thing to set in the model, but I can't find it.
Look into one of the many property editors that are around. Personally, I use a modified YAPE (to be found on qt-apps.org), but there are others as well.
So, I ended up using UserRoles to get the data from the model to the delegate.
I think there's a bug, however. When my delegate's createEditor is called, it is populated with the DisplayRole data, not the EditRole data. This makes for a problem with combo boxes. The DisplayRole is a string, but the EditRole is a list. I need that list type QVariant in the createEditor to create the right QWIdget.
I've gotten around this by having another UserRole to ask for the type of component to create, but it would be a whole lot simpler if createEditor was sent the EditRole data.