[Interest] Most direct path to using a QComboBox to edit a cell in a QTableView?

Tony Rietwyk tony at rightsoft.com.au
Wed Jun 27 04:06:21 CEST 2012


Hi Frank, 

> > Note that delegates don't have to be specific to a particular view.
> 
> Here's where I don't understand how things work.  Is a delegate associated
> with a view or a model?  I would think with the view because delegates
seem
> to do "view" kinds of things -- display and UI interaction, rather than
"model"
> things -- data.

Sorry I wasn't clear.  I meant that a given delegate class can be used in
any view that needs it - as long as you heed the warning about using
separate instances for each view.  

> And how, specifically, do I associate a delegate with a view (or a
specific part
> of a view)?

Search the docs for 'delegate' in QtAssisstant!  You will find the 3
flavours of setItemDelegate. 

The view holds reference(s) to the delegate(s), and uses it to paint and
edit the associated cells.  Simplest way in your case, is to create a
separate instance of the delegate class for each column that needs it.  

Tony.





More information about the Interest mailing list