QT QDateEdit 修改日历周六日颜色

效果图:

在这里插入图片描述

代码实现:

QCalendarWidget *pCalendarWidget = ui.dateEditBegin->calendarWidget();
QTextCharFormat f =pCalendarWidget->weekdayTextFormat(Qt::Monday);//获取周一字体格式
f.setForeground( QBrush(QColor("#0076ed")) );//替换字体颜色
QTextCharFormat weekdays = f;
ui.dateEditBegin->calendarWidget()->setWeekdayTextFormat(Qt::Sunday,weekdays);//设置周六日为新的字体格式
ui.dateEditBegin->calendarWidget()->setWeekdayTextFormat(Qt::Saturday,weekdays);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章