[Interest] Most direct path to using a QComboBox to edit a cell in a QTableView?

K. Frank kfrank29.c at gmail.com
Tue Jun 26 06:35:48 CEST 2012


Hello List!

I have a QTableView and I would like to use a QComboBox to insert and
modify its entries.  I'm looking for the simplest way to do this that uses
as much unmodified Qt functionality as possible.

At the moment I am thinking that I can use the class template
QStandardItemEditorCreator specialized on QComboBox as the most
direct way to do this.  Two questions:

Am I on the right track here?

What specifically do I need to do to make this work?  I don't really see
the full end-to-end logic (i.e., starting with a specific instance of a
QTableView) of how to hook all of the plumbing together.

(The model backing the QTableView happens to be a QSqlTableModel,
although -- and please correct me if I'm wrong -- this should be irrelevant.)

I've looked at a number of examples in the Qt documentation but the ones
I've found seemed to be concerned with writing custom delegates and
editors, rather than using existing delegate and editor classes already
provided by Qt.  Although I do believe I could achieve my end goal with
a custom delegate, I think using one would be more complicated than
necessary.  For example, as I understand it, QTableView uses QItemDelegate
as its default delegate, and that I can achieve my goal without changing this.

Assuming that I am on the right track, concrete details would be greatly
appreciated.  I'm lost in the multiple layers of the documentation at the
moment.

Thanks for any suggestions.


K. Frank



More information about the Interest mailing list