[PyQt] QDataWidgetMapper null values/ beforeInsert problem
bar tomas
bartomas at gmail.com
Sat Mar 6 15:06:01 GMT 2010
Hi,
I'm using a QDataWidgetMapper to map the fields in a database table to
the fields in a form.
If a field in the form is left empty I would like a null value to be
inserted in the database field.
However, empty fields are given a 0 value for numeric fields and an
empty string value for text fields by the mapper.
The mapper seems to ignore the db schema's default declarations.
I've tried a solution of defining a method activated by the
beforeInsert signal (SIGNAL("beforeInsert(QSqlRecord &)")) that
explicitely sets the value of the field to null with the setNull
method of the QSQLRecord class.
But even this is ignored by the mapper.
Do you have any hints of a solution to this problem?
Many thanks
Tomas Bar
More information about the PyQt
mailing list