1

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?

4

1 に答える 1

4

これを行う方法は、アイテム デリゲートを使用することです。ビュー/ウィジェットのsetItemDelegateメソッドの1 つを使用してデリゲートをインストールします。デリゲートはセルの表示と編集を担当し、クリック/キー処理を自分で行う必要はありません。

これに関するドキュメントは、モデル/ビュー プログラミング ガイドのデリゲート クラスのセクション (例付き) にあります。

于 2011-08-20T06:25:57.733 に答える