[PyQt] QSqlTableModel.beforeInsert signal (new style signal/slot)

KONTRA, Gergely pihentagy at gmail.com
Fri Dec 3 14:46:55 GMT 2010


Hi!

I am trying to connect the beforeInsert signal of a QSqlTableModel,
and having some problems.

I've found this similar thread:
http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg20117.html

However, I am using pyqt with py3k, so I prefer the new style signal
and slots, but I appreciate any working solution...

So my attempt based on the thread:
class BatteryMain(base_class, form_class):
       # ...
       def cycle_started(self, record):
               print("Inserting {!r}".format(record))

       def battery_load(self, filename):
               self.cycles_model = QSqlTableModel(db=self.battery_db)
               self.connect(self.cycles_model,
SIGNAL("beforeInsert(QSqlRecord
&)"), self.cycle_started)

RESULT:
QObject::connect: Cannot queue arguments of type 'QSqlRecord&'
(Make sure 'QSqlRecord&' is registered using qRegisterMetaType().)

Another attempt with new style signals and slots:

class BatteryMain(base_class, form_class):
       # ...
       @pyqtSlot('QSqlRecord &')
       def cycle_started(self, record):
               print("Inserting {!r}".format(record))

       def battery_load(self, filename):
               self.cycles_model = QSqlTableModel(db=self.battery_db)
               self.cycles_model.beforeInsert.connect(self.cycle_started)

RESULT:
 File "D:\prg\biQazo\biQazo.py", line 145, in battery_load
   self.cycles_model.beforeInsert.connect(self.cycle_started)
TypeError: connect() failed between beforeInsert(QSqlRecord) and unislot()

Could anybody tell me the correct syntax, please?

thanks
Gergo
+-[ Gergely Kontra <pihentagy at gmail.com> ]------------------+
|                                                           |
| Mobile:(+36 20)356 9656                                   |
|                                                           |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101203/a031a528/attachment.html>


More information about the PyQt mailing list