[SOLVED] PyQt5 Calendar Widget Children


I want to change the style of the calendar widget; however, I couldn’t change the background of the months drop-down menu (which I guess is ComboBox).Also there are some dark gray rects at the sides of the ‘Dec 2021’ text. How could I change them, too? Thanks in advance.

Here is what I’ve done so far;

        f"QDateEdit{{font-size: {int(settings['FONT_SIZE_PRIMARY']*0.6)}px; font-family: {settings['FONT']};\
    color: {settings['COLOR_PRIMARY']};background-color: {settings['COLOR_BG_PRIMARY']};}}"
        f"QCalendarWidget{{font-size: {int(settings['FONT_SIZE_SECONDARY']*0.7)}px;\
        font-family: {settings['FONT']};}}"
        f"QAbstractItemView{{background-color: {settings['COLOR_PRIMARY']};}}"



The month selection popup is actually a QMenu, so you need to use the appropriate selector.

The navigation bar has a hardcoded object name (qt_calendar_navigationbar), so you can use the #id selector.

QMenu {
    background: orange;
QMenu::item:selected {
    background: yellow;
    border-radius: 2px;
#qt_calendar_navigationbar {
    background: rgb(255, 168, 88)

All buttons in the navigation bar have object names (always have a look at the sources to check for those), so you can style them individually:

  • qt_calendar_prevmonth
  • qt_calendar_nextmonth
  • qt_calendar_monthbutton
  • qt_calendar_yearbutton
  • qt_calendar_yearedit

Answered By – musicamante

Answer Checked By – Dawn Plyler (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *