[PyQt] Incorrect conversion from datetime to QVariant

Alexandr N Zamaraev tonal at promsoft.ru
Fri Oct 10 10:40:39 BST 2008


My Environment:
WinVista Home Basic Ru + sp1
Python 2.5.2
sip 4.7.7 (from source, build gcc mingw 3.4.5)
Qt 4.4.1 (from source, build gcc mingw 3.4.5)
PyQt 4.4.3 (from source, build gcc mingw 3.4.5)

Code snap:
 >>> from datetime import datetime
 >>> from PyQt4 import QtCore
 >>> u'%s' % datetime.today()
u'2008-10-10 16:37:57.822000'
 >>> '%s' % QtCore.QVariant(datetime.today()).toString()
u'2008-10-10'
 >>> QtCore.QVariant(datetime.today()).typeName()
'QDate'

Why QtCore.QVariant(datetime.today()).typeName() is 'QDate'?
Mast by 'QDateTime'.


More information about the PyQt mailing list