void Overview::UpdateCalendarDay(QDateEdit *dateedit, QDate date) { QCalendarWidget *calendar = dateedit->calendarWidget(); QTextCharFormat bold; QTextCharFormat cpapcol; QTextCharFormat normal; QTextCharFormat oxiday; bold.setFontWeight(QFont::Bold); cpapcol.setForeground(QBrush(Qt::blue, Qt::SolidPattern)); cpapcol.setFontWeight(QFont::Bold); oxiday.setForeground(QBrush(Qt::red, Qt::SolidPattern)); oxiday.setFontWeight(QFont::Bold); bool hascpap = p_profile->FindDay(date, MT_CPAP) != nullptr; bool hasoxi = p_profile->FindDay(date, MT_OXIMETER) != nullptr; //bool hasjournal=p_profile->GetDay(date,MT_JOURNAL)!=nullptr; if (hascpap) { if (hasoxi) { calendar->setDateTextFormat(date, oxiday); } else { calendar->setDateTextFormat(date, cpapcol); } } else if (p_profile->GetDay(date)) { calendar->setDateTextFormat(date, bold); } else { calendar->setDateTextFormat(date, normal); } calendar->setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames); }
void tst_QCalendarWidget::resetTextFormat() { QCalendarWidget calendar; QTextCharFormat format; format.setFontItalic(true); format.setForeground(Qt::green); const QDate date(1984, 10, 20); calendar.setDateTextFormat(date, format); calendar.setDateTextFormat(QDate(), QTextCharFormat()); QCOMPARE(calendar.dateTextFormat(date), QTextCharFormat()); }