[PyKDE] [PyQt3] problem using a custom QSqlCursor on a QDataTable

Phil Thompson phil at riverbankcomputing.co.uk
Sun Oct 8 16:26:33 BST 2006

On Saturday 07 October 2006 12:13 pm, Hans-Peter Jansen wrote:
> Hi Phil,
> here's is a nasty problem with using a custom QSqlCursor on a
> QDataTable, I didn't found a workaround yet (other than avoiding this
> all together, which isn't a feasible option here):
> Whenever the update() and delRecords() methods on the parent class are
> called, they show recursive behavior, just like (wrongly) calling
> self.update(invalidate) in the custom QSqlCursor class.
> Another aspect on this problem is, that QDataTable insists on a 3 arg
> signature when calling sqlCursor().update(), but the base class must be
> called with the 2 arg variant.
> Btw: Qt 3.3.6 itself doesn't provide any arguments, as seen in
> sql/qdatatable.cpp [around line 1144]:
>     case QSql::Yes: {
> #ifndef QT_NO_CURSOR
>         QApplication::setOverrideCursor( Qt::waitCursor );
> #endif
>         emit beforeUpdate( d->editBuffer );
>         b = sqlCursor()->update();
> #ifndef QT_NO_CURSOR
>         QApplication::restoreOverrideCursor();
> #endif
> You find a small self containing script exploring this problem attached.
> You may want to adjust the db variables on top of the script beforehand.
> Creating the mysql database is done with:
> mysql < t.sql
> provided, that you have valid access parameter in your .my.cnf client
> section. Beware, this sql script will silently drop a database named t,
> if one exists.
> Running qdatatableproblem.py should show you a small table, where
> inserting works as expected, but updating and deleting does not (here
> at least). Some diagnostics are printed on the console.
> Any hints fixing this problem are highly appreciated.

Your update() will be called for both of the C++ signatures. Your code doesn't 
seem to be doing enough parsing of the argument types to work out which one 
it is.


More information about the PyQt mailing list