QDateEdit - Change the font color of the Date , if it is a Holiday?



  • Hi...

    I have a QDateEdit. In that if the user enters a Date, which is of a holiday, then the color of the date should be changed to indicate that the mentioned date was a holiday... How can i specify the QDateEdit that these are the Holidays and only the color of these Dates should be changed.. Please post your suggestions....

    Example: If the user enters, (12-25-yyyy) then color of the Date should be changed to indicate the user that this date is invalid.
    and if he enters (02-27-2013) then it should display it as normal.

    Thanks & Regards...



  • For changing background or font format for a QDateEdit i use:
    @void QCalendarWidget::setDateTextFormat ( const QDate & date, const QTextCharFormat & format )@



  • Thanks qxoz for your reply. Can u please suggest me how to specify the dates of holidays to a QDateEdit....

    Thanks & Regards...



  • Well, just create an arbitrary container, put all dates you want to be holidays in there, and check if a date is contained in the holidays container, if so, apply your custom font.



  • Thanks utcenter for your suggestion...

    Another thing, I am trying to create a custom calendar widget, in that the weekends are already shown in red color. Now i just want to change the color of the public holidays in red color. How can i do that in a QCalendar Widget.

    Thanks & Regards...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.