[Qt-interest] Issue with QDataWidgetMapper

Reaves, Timothy treaves at silverfieldstech.com
Mon Oct 18 15:46:29 CEST 2010


I have an application where there is a QListView, and a form.  The user
clicks on one of the entries in the list, it is displayed in the form.
Fairly common.  It uses a single instance of QSqlTableModel as the model for
both the list and the data mapper.  This works.

For a couple of reasons, I'm replacing the SQL table model for a custom
table model.  My model subclasses QAbstractTableModel.  In the data method,
I get an object from an internal collection, and then call property() on
this object ( I also have a map of column index to property value).  I then
simply replaced the setModel() parameter with this new model.  This works
for the list, but not the data mapper (the form is always blank).

When I set up my mapper, I have tried both int indexes (that index into the
map in my model class), and I have tried the property name too.  When I add
a log message to my data() method in my model, I never see any column asked
for but the first one.  I assume that this is why the list is displaying
correctly.  I can attach a second signal/slot, and see that they still fire
correctly, so the mapper should be being informed of the new selection.  It
just doesn't seem to work.

I have tried looking at the calls to data() in my model, but I do not know
how many calls I should be expecting; I was doing this in an attempt to
determine if the method was being called 'enough', just with the ring column
number.  I can't tell.  I do know it is called 8-10 times for each list
selection.

Can someone provide me with any pointers in trying to track this down?  I'm
not even really sure where to start.  I could try to debug, but, replacing
one model with a different one should just work.

Any advice appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101018/8ef75145/attachment.html 


More information about the Qt-interest-old mailing list