PDA

View Full Version : Can't recognize the beforeInsert signal



scot_hansen
29th October 2010, 18:05
The program I'm writting displays a MySQL table using QSqlModelTable and QTableView. The user can add additional rows to the table. When the user is done entering data for a row, I want the user to enter additional data.

To pick up the signal that the user is done entering the row, I setup the connection and the event handler this way:

self.connect(self.mdlFuelMaps, QtCore.SIGNAL("beforeInsert(QSqlRecord)"),self.insertRecord)

#event handler
def insertRecord(self,data):
print "record inserted"

I set the mdlFuelMaps edit strategy this way:

self.mdlFuelMaps.setEditStrategy(QSqlTableModel.On FieldChange)

I tried the other 2 methods but OnFieldChange worked the best.
When the row is inserted, I never see the print string displayed. self.mdlFuelMaps is formed from QSqlTableModel and displays the data correctly.

I've tried several ways to code the signal with no luck. I am imporint the QSqlRecord module at the beginning.

Finally, I am using Python 2.7 and PyQt4.6 on Windows XP. I've searched on-line and saw someone else with this issue. Unfortnately, there was no final solution.

I realize this is a stupid question.

Thank you.