tags:

views:

275

answers:

1

I'm using PyQt 4.4.3.

I've got this code, which should clear all formats in the QCalendarWidget:

cal.setDateTextFormat(QDate(), QDateTextFormat())

According to the documentation this should work:

QCalendarWidget::setDateTextFormat(QDate &date, QTextCharFormat &format)
If date is null, all date formats are cleared.

QDate::QDate()
Constructs a null date. Null dates are invalid.

I've tried narrowing down the problem like this:

>>> QDate().isNull()
True
>>> cal.dateTextFormat()
{PyQt4.QtCore.QDate(-4713, 1, 1): PyQt4.QtGui.QTextCharFOrmat object}

Obviously, QDate() is interpreted as being in the year -4713 instead of being null.

Any idea what I need to change to make it work?

Edit: The problem is, that the calendar isn't reset using this method.

+1  A: 

QDate(-4713, 1, 1) is the same as null,

I think that's the way in QCalendar to set the default QTextCharFormat of the calendar. QCalendar::dateTextFormat() is returning a map with all special formats and (I think) the default format.

Or could be a bug, notify to the trolls your problem.

xgoan