Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell Qt to always show an editor in a QTableView?

I've got a QTableView for which I want to display the last column always in edit mode. (It's a QComboBox where the user should be able to always change the value.)

I think I've seen the solution in the Qt documentation, but I can't find it anymore. Is there a simple way of doing it?

I think I could archive this effect by using openPersistentEditor() for every cell, but I'm looking for a better way. (Like specifying it only one time for the whole column.)

like image 604
Georg Schölly Avatar asked Feb 09 '09 14:02

Georg Schölly


1 Answers

One way to get the automatic editing behaviour is to call the view's setEditTriggers() function with the QAbstractItemView::AllEditTriggers value.

To display the contents of a given column in a certain way, take a look at QAbstractItemView::setItemDelegateForColumn(). This will let you specify a custom delegate just for those items that need it. However, it won't automatically create an editor widget for each of them (there could in principle be thousands of them), but you could use the delegate to render each item in a way that makes it look like an editor widget.

like image 183
David Boddie Avatar answered Oct 16 '22 10:10

David Boddie