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.)
There are two possibilities:
Using setIndexWidget
, but Trolltech writes:
This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass QItemDelegate instead.
(And it breaks the Model/View pattern…)
Or using a delegate's paint
method. But here you have to implement everything like enabled/disabled elements yourself.