<div class="gmail_quote">Hi!<br>
<br>
I am trying to connect the beforeInsert signal of a QSqlTableModel,<br>
and having some problems.<br>
<br>
I've found this similar thread:<br>
<a href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg20117.html" target="_blank">http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg20117.html</a><br>
<br>
However, I am using pyqt with py3k, so I prefer the new style signal<br>
and slots, but I appreciate any working solution...<br>
<br>
So my attempt based on the thread:<br>
class BatteryMain(base_class, form_class):<br>
# ...<br>
def cycle_started(self, record):<br>
print("Inserting {!r}".format(record))<br>
<br>
def battery_load(self, filename):<br>
self.cycles_model = QSqlTableModel(db=self.battery_db)<br>
self.connect(self.cycles_model, SIGNAL("beforeInsert(QSqlRecord<br>
&)"), self.cycle_started)<br>
<br>
RESULT:<br>
QObject::connect: Cannot queue arguments of type 'QSqlRecord&'<br>
(Make sure 'QSqlRecord&' is registered using qRegisterMetaType().)<br>
<br>
Another attempt with new style signals and slots:<br>
<br>
class BatteryMain(base_class, form_class):<br>
# ...<br>
@pyqtSlot('QSqlRecord &')<br>
def cycle_started(self, record):<br>
print("Inserting {!r}".format(record))<br>
<br>
def battery_load(self, filename):<br>
self.cycles_model = QSqlTableModel(db=self.battery_db)<br>
self.cycles_model.beforeInsert.connect(self.cycle_started)<br>
<br>
RESULT:<br>
File "D:\prg\biQazo\biQazo.py", line 145, in battery_load<br>
self.cycles_model.beforeInsert.connect(self.cycle_started)<br>
TypeError: connect() failed between beforeInsert(QSqlRecord) and unislot()<br>
<br>
Could anybody tell me the correct syntax, please?<br>
<br>
thanks<br>
Gergo<br>
<font color="#888888">+-[ Gergely Kontra <<a href="mailto:pihentagy@gmail.com">pihentagy@gmail.com</a>> ]------------------+<br>
| |<br>
| Mobile:(+36 20)356 9656 |<br>
| |<br>
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+<br>
</font></div><br>