PDA

View Full Version : how to use setDateTextFormat() using pyqt



ad3d
20th January 2011, 11:31
hi guys

i am trying to color specific dates of QCalenderWidget using setDateTextFormat() function.
i am using QDateEdit in the program n my piece of code is


self.dob_date = QtGui.QDateEdit(self.basic_grp)
self.dob_date.setGeometry(QtCore.QRect(89,110,100, 20))
self.dob_date.setCalenderPopup(True)
self.dob_date.setObjectName("dob_date")

#creating QDate as setDateTextFormat(QDate date, QTextCharFormat color)
date = 13
month = 01
year = 2011
item = QtCore.QDate(year,month,date)

#creating QTextCharFormat as setDateTextFormat(QDate date, QTextCharFormat color)
kk = QtGui.QTextCharFormat()
kk.setForeground(QtGui.QColor('red'))

#creating calenderwidget for respective QDateEdit object
omg = self.dob_date.calenderWidget()

#using setDateTextFormat() to change color of QDate i.e. 13-01-2011 to "red"
omg.setDateTextFormat(item,kk)


This code is not giving any error but when i click on respective QDateEdit to popup QCalenderWidget that date is in black color not in red..this code is not changing color of the specified date...Can someone tell me where i am going wrong????

Thanx in advance