Many thanks for your help. I've corrected the code following your
suggestion, but the test method still does not get called, although
new records get submitted to the database:

self.model = QSqlRelationalTableModel(self)
self.connect(self.model, SIGNAL("beforeInsert(QSqlRecord *)"), self.test)

def test(self, record):
       print "test"

I was wondering, it is the QSqlRelationalTableModel object that emits
the beforeInsert signal, or have I got that wrong?

Thanks again

On Thu, Jan 21, 2010 at 1:43 PM, Phil Thompson
<p...@riverbankcomputing.com> wrote:
> On Thu, 21 Jan 2010 13:38:45 +0000, bar tomas <barto...@gmail.com> wrote:
>> Hi,
>>
>> I've created a QDataWidgetMapper that uses a QSqlRelationalTableModel
>> to edit the records of database table.
>> I've tried using the signal beforeInsert to do some validation before
>> the data is submitted to the database but I have a problem
>> intercepting the signal (the slot method test  just never executes).
>> Here is a snippet of the relevant code:
>>
>> self.model = QSqlRelationalTableModel(self)
>>
>> self.connect(self.model, SIGNAL("beforeInsert(record)"), self.test)
>>
>>
>> def test(self, record):
>>     print "test"
>>
>> Is there something wrong in the way I've declared the connection?
>
> Yes - use the type of the signal argument (ie. QSqlRecord) not its name. Or
> use the new-style connection API which will do it for you.
>
> Phil
>
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to