Reimplementing the QCalendarWidget:paintCell() event

200 views
Skip to first unread message

Ralf Van Bogaert

unread,
Apr 19, 2012, 3:57:15 AM4/19/12
to lqt-bi...@googlegroups.com
Hiya,

My app has a table that allows a user to insert dates. These can be edited using a QDateTimeEdit, with optional QCalendarPopup.

However to prevent being able to select dates that are already inserted, I need to paint these cells differently, by reimplementing the paintCell() method.

The following example marks all 11th days of the month in red;

local C=QCalendarWidget()

function C:paintCell(Painter,Rect,Date)
if Date:day()==11 then
Painter:fillRect(Rect,'red')
Painter:save()
Painter:setPen'white'
Painter:drawText(Rect,QString.number(Date:day()))
Painter:restore()
else
-- QCalendar:paintCell(Painter,Rect,Date)
end
end

However, the commented line in red is needed to paint all other cells normally,
but it crashes lqt with the message that the method is not available.

I have been trying some syntax variations but I can't find the correct one.

Can you help?

Regards

Ralf






Reply all
Reply to author
Forward
0 new messages