wrongusername
wrongusername

Reputation: 18918

QComboboxes in a QTableWidget

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?

Upvotes: 1

Views: 702

Answers (1)

Mat
Mat

Reputation: 206859

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).

Upvotes: 4

Related Questions