[Qt-interest] QTableView and delegate

Wolfgang Pausch Wolfgang.Pausch at uibk.ac.at
Thu Nov 5 20:59:42 CET 2009


Hello,

if I have a read-only QTableView with a model containing integers in some
column, and want to translate them into human-readable strings before
displaying them in the table, what is the best design?

I first thought about using a column delegate, however I noticed that it is only
called if flags() returns Qt::ItemIsEditable, which is not what I want in a
read only table...  And even if flags() returns Qt::ItemIsEditable, the
delegate seems to become active only if I click on the cell.

I think I might get what I want by using QAbstractItemView::setIndexWidget for
each cell where I want to translate ints to strings.  But this would mean that
I (a) would need custom widget classes, (b) would have several extra widgets
per row and (c) would have to set them manually e.g. when adding/removing rows.

What do you think, is the latter really the right design, or is there some
simpler solution I missed so far?

Thanks,

Wolfgang



More information about the Qt-interest-old mailing list