C++ 如何在QComboBox中仅显示月份和年份

C++ 如何在QComboBox中仅显示月份和年份,c++,qt,qcombobox,qdateedit,C++,Qt,Qcombobox,Qdateedit,我想在一个组合框中只显示月份,就像年份一样,我试图在QDateEdit中这样做,但它对我不起作用,所以我想单独做,只显示月份和年份,而不是天数,提前谢谢 ui->dateTimeEdit->setDisplayFormat("MM/yyyy"); ui->dateTimeEdit->setCurrentSection(QDateTimeEdit::MonthSection); ui->dateTimeEdit->setCalen

我想在一个组合框中只显示月份,就像年份一样,我试图在QDateEdit中这样做,但它对我不起作用,所以我想单独做,只显示月份和年份,而不是天数,提前谢谢

  ui->dateTimeEdit->setDisplayFormat("MM/yyyy");
  ui->dateTimeEdit->setCurrentSection(QDateTimeEdit::MonthSection);
  ui->dateTimeEdit->setCalendarPopup(true);
这是我的小部件的代码,正如你在图片中看到的,日子还在继续,这就是为什么我想把月份和年份分开,分别放在一个组合框中


我想你需要两个组合框,一个用于年度,一个用于月度,除非你想在一个组合框中列出所有年度/月度组合(
Enero 2000
Febrero 2000,
,…,
Diciembre 2000
Enero 2001
,…)。