[Qt-interest] QTableView and delegate
KC Jones
kc at asperasoft.com
Fri Nov 6 23:19:07 CET 2009
> I just want to exchange the data the table should
> display, not the way how some string (5, "foo", etc.) is rendered.
Sounds to me like you should implement a custom model, not a delegate.
Esben suggested the right approach above. If you are using some
variant of a QSqlQueryModel now, your specialized model can be
trivially small. Just override the data() method, and only handle the
Qt::DisplayRole case. I do this to format timestamps. The data()
method maps the QDateTime objects in my db onto QStrings. Very
simple, small, effective.
In another context I need to implement a custom item delegate to
specialize the paint() method. That is a lot more work that is
forcing me to learn more about the rendering machinery than I care to
know. If you can get it done with a custom model, take that approach.
More information about the Qt-interest-old
mailing list