[PyKDE] QSqlEditorFactory.createEditor invocation problem, possibly PyQt bug

Hans-Peter Jansen hpj at urpla.net
Mon Jun 17 23:08:00 BST 2002


Hi Phil et al.,

after mangling my code for some hours, I'm suspect a PyQt problem
in QSqlEditorFactory.

This is the code in qt3/examples/sql/overview/table3/main.h:

class CustomSqlEditorFactory : public QSqlEditorFactory
{
    Q_OBJECT
    public:
	QWidget *createEditor( QWidget *parent, const QSqlField *field );
};

and in main.cpp:

QWidget *CustomSqlEditorFactory::createEditor(
    QWidget *parent, const QSqlField *field )
{
    if ( field->name() == "statusid" ) {
	QWidget *editor = new StatusPicker( parent );
	return editor;
    }

    return QSqlEditorFactory::createEditor( parent, field );
}

My corresponding python version:

class CustomSqlEditorFactory(QSqlEditorFactory):
    def __init__(self):
        print "CustomSqlEditorFactory.__init__"
        QSqlEditorFactory.__init__(self)

    def createEditor(self, parent, field):
        print "createEditor:", parent, field
        if str(field.name()) == "statusid":
            return StatusPicker(parent)
        else:
            return QSqlEditorFactory.createEditor(parent, field)

The constuctor gets called, but createEditor doesn't. The PyQt docs
state, this class is fully implemented, but Boudewijn gave me the
hint, that it has two methods with the same name and the same number
of arguments. Could it be the problem here?

TIA,
  Hans-Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sqltable3.py
Type: application/octet-stream
Size: 3216 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20020617/55e0dc55/sqltable3.obj


More information about the PyQt mailing list