Adding notes to QCalendarWidget
-
I have managed to highlight dates on QCalendar, but I want to add notes to those such that when those dates are clicked the user can see the notes. How can I do it?
QDate dateToHighlight(2024, 7, 23); QTextCharFormat highlightFormat; highlightFormat.setBackground(Qt::yellow); calendar->setDateTextFormat(dateToHighlight, highlightFormat);
-
I have managed to highlight dates on QCalendar, but I want to add notes to those such that when those dates are clicked the user can see the notes. How can I do it?
QDate dateToHighlight(2024, 7, 23); QTextCharFormat highlightFormat; highlightFormat.setBackground(Qt::yellow); calendar->setDateTextFormat(dateToHighlight, highlightFormat);
Maybe add a layout with labels below or next to it?!
Or maybe even use a proper model / view.Edit:
The title saysQCalendarWidget
, the postQCalendar
?!
QCalendarWidget
is a (kinda) closed widget in itself (likeQTableWidget
vs aQTableView
approach for table modelling)... you could embed it in your own widget and add your layout, as I mention above.
Another way is writing your own calendar notes widget from scratch usingQCalendar
and a model/view for managing the notes and other data.
Unless there is already something like that around I haven't seen yet. -
I have managed to highlight dates on QCalendar, but I want to add notes to those such that when those dates are clicked the user can see the notes. How can I do it?
QDate dateToHighlight(2024, 7, 23); QTextCharFormat highlightFormat; highlightFormat.setBackground(Qt::yellow); calendar->setDateTextFormat(dateToHighlight, highlightFormat);
@symHeisenberg You could show a widget when https://doc.qt.io/qt-6/qcalendarwidget.html#clicked is emitted where you show the notes for the date which was clicked.