PDA

View Full Version : Questions on using custom widgets in a QTableView



d_stranz
25th October 2010, 22:23
I want to use a QTableView to display the contents of a custom model. In some of the columns, I want to display the appropriate data using a custom widget (a QwtPlot, to be precise).

I previously implemented something like this using derived QTableWidget class and the setCellWidget() mechanism. This is awkward to use with models like mine that change frequently. (My model displays details for the selected "parent" item in another model). I would rather use a standard QTableView and not have to derive a custom one.

I am confused about how to implement this. I have read the other threads about using custom widgets, custom delegates, models, and views and they have left me more confused.

Should I be using a custom delegate?

The QwtPlot is mostly display-only; the only interaction required would be to zoom in on regions of the plot but this doesn't require any updates to the model.

My understanding of custom delegates is that they are used mostly for model editing and are created on demand when the user clicks a cell. Is this correct?

Any advice or pointers to code I could study would be appreciated.