I would like one of the cells in a开发者_如何转开发 table to be a QComboBox. However, I don't want them displayed as such all the time, only when a user selects that cells. Are there any more convenient ways of accomplishing this than detecting when a cell's been clicked, removing the item in the cell and replacing it with a widget, and switching it back to an item when the user's clicked away from that cell?
The way to do that is to use item delegates. You install your delegates using one of the setItemDelegate methods of the view/widget. The delegate is responsible for display and editing of the cell, and you don't have to do the click/key handling yourself.
The documentation for this is in the model/view programming guide delegate classes section (with examples).
精彩评论