[PyKDE] Qvariant problem (it looks like)

Hans-Peter Jansen hpj at urpla.net
Fri Jun 21 20:25:00 BST 2002


Hi Phil et al.,

I hacked a bit on sqltable4.py to circumvent current PyQt Q_PROPERTY 
problems. My solution is simply mapping the QComboBox index to the name.
Working fine so far. I thought, a further improvement would be using
a calculated field "Monthly Salary", so I tried to imitate the qt
sql/overview/subclass4 example by subclassing QSqlCursor. In the
overloaded calculateField method, it's necessary to return a QVariant:

    def calculateField(self, name):
        if str(name) == "monsalary":
            v = self.value("salary").toDouble() / 12
            return QVariant(v)
        return QVariant(QString.null)

Unfortunately, this produces strange error messages:

QSqlField::setValue: monsalary cannot cast from QKeySequence to (null)

Even the "return QVariant(QString.null)" statement gives:

QSqlField::setValue: monsalary cannot cast from QString to (null)

Any ideas, what happens here?

This reminds me, that the docu states a lot QVariants variants as
not yet implemented. Is this correct anymore?

I've attached a reworked testdb.sql script to reflect the 
necessary changes for the StatusPicker problem.

G'day,
  Hans-Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sqltable4.py
Type: application/octet-stream
Size: 4617 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20020621/2c69a33a/sqltable4.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testdb.sql
Type: application/octet-stream
Size: 1295 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20020621/2c69a33a/testdb.obj


More information about the PyQt mailing list