[PyQt] QDateEdit is ignoring the sip API level 2

Daniele Esposti expo at expobrain.net
Tue Jun 7 11:46:08 BST 2011


Well, datetime package doesn't support operations with QDate
instances, for example QDateEdit().date() + datetime.timedelta(days=1)
raises a TypeError.

IMHO it's more clear to return a datetime instance instead a Qt one,
like the QLineEdit.tex() method returns a unicode string instead of a
QString if the sip API level for QString is set to 2. Again, IMHO.


On 7 June 2011 11:19, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On Tue, 7 Jun 2011 10:55:46 +0100, Daniele Esposti <expo at expobrain.net>
> wrote:
>> This simple example raise an AssertionError because the type of the
>> value returned by the QDateEdit.date() property is a QDate instance
>> even the sip API level for QDate is set to 2.
>>
>> Here the example which triggers the problem:
>>
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>>
>> import datetime
>> import sip
>>
>> sip.setapi( "QDate", 2 )
>>
>> from PyQt4 import QtGui
>>
>>
>> app = QtGui.QApplication( [] )
>>
>> assert( isinstance( QtGui.QDateEdit().date(), datetime.date ) )
>
> The only difference in behaviour is the value returned by hash(), see...
>
> http://www.riverbankcomputing.com/static/Docs/PyQt4/html/python_v3.html#qdate
>
> Phil
>



-- 
Daniele Esposti

My Blog http://www.expobrain.net
LinkedIn http://www.linkedin.com/in/danieleesposti
Twitter http://www.twitter.com/#!/expobrain


More information about the PyQt mailing list