[Qt-interest] Issue with QDataWidgetMapper & QCheckBox

Timothy Reaves treaves at silverfieldstech.com
Mon Dec 14 00:07:52 CET 2009


On Dec 13, 2009, at 5:51 PM, Timothy Reaves wrote:

> 
> On Dec 13, 2009, at 4:45 PM, Lorenzo Masini wrote:
> 
>> Il giorno dom, 13/12/2009 alle 16.34 -0500, Timothy Reaves ha scritto: 
>>> 	I have a a QDataWidgetMapper set up for a form.  There are two QCheckBoxes on this form.  The values display the checked state properly, but changes are not saved.  When I call submit() on the mapper, it fails with this error:
>>> QSqlError(20, "Unable to fetch row", "datatype mismatch") 
>>> 
>>> 	The two columns are defined as BOOLEAN in a SQLite database. When I listen to the table model beforeUpdate, the fields are being passed as QString "true" or "false".  What is the correct way to convert them to BOOLEAN?
>> 
>> Why aren't you using the "checked" property?
>> 
>> cheers
>> Lorenzo
>> 
> 
> 	I am setting the mapping thus:
> 
> telescopeMapper->addMapping(ui->telescopeVFlip, 4, "checked");
> telescopeMapper->addMapping(ui->telescopeHFlip, 5, "checked");
> 
> Is that not correct?


	I think this might be because Qt is sending true & false (as string), and the sqlite can not convert to the 1 or 0 (as int) that is its BOOLEAN datatype.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091213/3400ac1a/attachment.html 


More information about the Qt-interest-old mailing list