Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
A delegate works fine in one QTableView but not visible in an other - what might be the issue?
I have a delegate which just overrides createEditor and setEditorData to create a label which displays a pixmap. This works perfectly fine in one table view in a dialog but the label isn't shown in a second, different, dialog, which uses a different QTableView with a different model but the same delegate.
- My code does call openPersistentEditor in both cases.
- createEditor in the delegate gets called and successfully creates the label.
- setEditorData is called once.
- flags() in the model returns identical values for both cases.
- The model provides the correct data (since there delegate qlabel isn't shown the qtableview displays the data as string instead and it's correct)
Any idea of what I might be missing? Some special setting in the table view which is required for delegates to be positioned correct?
but the same delegate
What does this mean? Hopefully these are two different instances:
Warning: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed
yes, there is two difference instances of the same class.
The please provide a minimal, compilable example.
Solved: The view destroys all delegates when the model is reset. In hindsight one can say that this is obvious but it wouldn't hurt if it was included in the documentation.
Sorry but I don't think you're right, see QAbstractItemView::setItemDelegate(): QAbstractItemView does not take ownership of delegate.
Please provide a minimal, compilable example.