开发者

QComboboxes in a QTableWidget

开发者 https://www.devze.com 2023-03-29 16:48 出处:网络
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 conveni

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号