30 connect(saveAction, &QAction::triggered,
this, &MainWindow::saveFile);
32 connect(calendarAction, &QAction::triggered,
this, &MainWindow::insertCalendar);
56 QTextCursor cursor(editor->textCursor());
57 cursor.movePosition(QTextCursor::Start);
59 QTextCharFormat format(cursor.charFormat());
60 format.setFontFamily(
"Courier");
62 QTextCharFormat boldFormat = format;
63 boldFormat.setFontWeight(QFont::Bold);
66 cursor.insertText(
" ", boldFormat);
68 QDate date = QDate::currentDate();
69 int year = date.year(), month = date.month();
71 for (
int weekDay = 1; weekDay <= 7; ++weekDay) {
72 cursor.insertText(QString(
"%1 ").arg(QLocale::system().dayName(weekDay), 3),
77 cursor.insertText(
" ", format);
79 for (
int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
80 cursor.insertText(
" ", format);
83 for (
int day = 1; day <= date.daysInMonth(); ++day) {
85 int weekDay = QDate(year, month, day).dayOfWeek();
87 if (QDate(year, month, day) == date)
88 cursor.insertText(QString(
"%1 ").arg(day, 3), boldFormat);
90 cursor.insertText(QString(
"%1 ").arg(day, 3), format);
94 cursor.insertText(
" ", format);