This article introduces various operations of the QCalendarWidget control in detail, such as: setting the text format of the calendar , setting the size of the calendar , moving the calendar , hiding & displaying the calendar , setting the maximum value of the calendar time , setting the minimum value of the calendar time , clicking the signal & slot , calendar change signal & slot , double-click mouse signal & slot and other operations.
This series of QT comprehensive and detailed articles currently has a total of 19 articles and is currently being updated continuously. This series of articles describes the basic operation and use of QT controls in more detail. Thank you for your attention, likes, and collections.
The author of this article is original, please attach the source of the article and the link of this article for reprinting.
QT QCalendarWidget control use detailed directory
1 Format the text of the calendar
2 Set the size of the calendar
6 Set the calendar time minimum
8 Calendar change signals & slots
10 Double click mouse signal & slot
1 Format the text of the calendar
//设置日历的文本格式
ui->calendarWidget->setFont(QFont("Timers",8,QFont::Bold));
2 Set the size of the calendar
//设置日历的大小
ui->calendarWidget->resize(300,200);
3 Calendar mobile
//日历移动
ui->calendarWidget->move(0,200);
4 Calendar Hide & Show
//日历隐藏,显示用show()
//ui->calendarWidget->hide();
5 Set calendar time maximum
QDate dateMax(2025,3,5);
ui->calendarWidget->setMaximumDate(dateMax);
///date.toString("yyyy:MM:dd")
6 Set the calendar time minimum
QDate dateMin(1999,3,5);
ui->calendarWidget->setMinimumDate(dateMin);
7 Click Signals & Slots
connect(ui->calendarWidget,SIGNAL(clicked(QDate)),this,SLOT(clickedSlot(QDate))); //单击信号
//单击信号
void MainWindow::clickedSlot(const QDate date)
{
qDebug()<< "clickedSlot";
qDebug()<< date;
}
8 Calendar change signals & slots
connect(ui->calendarWidget,SIGNAL(selectionChanged()),this,SLOT(calendarChanged())); //日期改变
//改变信号 重新选择日期触发
void MainWindow::calendarChanged()
{
qDebug()<< "日期改变:" << ui->calendarWidget->selectedDate();//打印当前时间
}
9 Date Change Signals & Slots
connect(ui->calendarWidget,SIGNAL(currentPageChanged(int,int)),this,SLOT(currentPageChanged(int,int))); //重新选择日期
//重新选择日期
void MainWindow::currentPageChanged(int year, int month)
{
qDebug()<< "currentPageChanged";
qDebug()<< "重新选择日期: " << year << " " << month;
}
10 Double click mouse signal & slot
connect(ui->calendarWidget,SIGNAL(activated(QDate)),this,SLOT(activatedChanged(QDate))); //双击信号
//双击信号 日期触发
void MainWindow::activatedChanged(const QDate date)
{
qDebug()<< "activatedChanged";
qDebug()<< "双击信号:" <<date;
}
11 Other articles
QT TextEdit Control_Gemini Breakpoint Blog-CSDN Blog_qt textedit
Detailed explanation of the use of QT QComboBox - Gemini Breakpoint Blog - CSDN Blog
Detailed explanation of QT QtableView operation
Qt QStandardItemModel (1. Super detailed usage)_ Gemini Breakpoint Blog-CSDN Blog_qstandardmodel
Qt QStandardItemModel (2. Super detailed function)_Gemini breakpoint blog-CSDN blog_qstandarditemmodel click event
Detailed use of QT QRadioButton - Gemini Breakpoint Blog - CSDN Blog - qt radiobutton
Detailed use of QT QLineEdit_ Gemini Breakpoint Blog-CSDN Blog_qt qlineedit
Detailed explanation of Qt QMessageBox use - Gemini Breakpoint Blog - CSDN Blog - qt message
QChart Line Chart, Pie Chart, Bar Chart, Curve Chart_ Gemini Breakpoint Blog-CSDN Blog_qchart Style
Detailed explanation of QChart properties_ Gemini Breakpoint Blog-CSDN Blog_setanimationoptions
Use of QCharts QValueAxis_Gemini Breakpoint Blog-CSDN Blog_qvalueaxis
Qt 5 wait prompt box (open source dynamic graph)_ Gemini Breakpoint Blog-CSDN Blog_qt wait dialog box
QtDataVisualization Data 3D Visualization_Gemini Breakpoint Blog-CSDN Blog_qtdatavisualizatio
Detailed explanation of the use of QT QSpinBox integer counter control - Gemini Breakpoint Blog - CSDN Blog
QT QDoubleSpinBox floating-point counter control (detailed use)_Gemini Breakpoint Blog-CSDN Blog_qdoublespinbox Signal Slot
QT QSlider, QHorizontalSlider, QVerticalSlider control use detailed explanation_ Gemini Breakpoint Blog-CSDN Blog_qslider setting step size
Detailed explanation of the use of QT QTabWidget control - Gemini Breakpoint Blog - CSDN Blog