[PyQt] QStandardItemModel: problems with non-string data
nulla.epistola at web.de
Wed Jul 4 12:24:35 BST 2012
I want to show records containing a numeric field and a date field in a
QTableView connected to a QStandardItemModel.
The numeric field: if that gets its value from a floating point literal,
this value is displayed in the view. If the value comes from a database
table the view column is empty. The database column is Numeric(9,2), the
RDBMS is PostgreSQL.
If I create the QStandardItem for the date column using a Python
datetime the view column is empty. If I use a QDate it's displayed
correctly. This is independent of the data source. I don't understand
it, because the documentation for QDate says: "A Python date object may
be used whenever a QDate is expected". Same thing for datetime objects.
And there is no direct conversion from a Python date or datetime to a
QDate or QDateTime.
I can send an example if necessary - but changing the database to SQLite
might alter the behavior, and everything else would need adapting.
Python 3.2.3, PyQt4 4.9.4, Windows 7 (64 bit, german - might this be a
Thank you for hints,
More information about the PyQt