Как убрать стрелочку возле выбора месяца в QCalendarWidget?
Есть код для внешнего вида календаря, сделанного в PyQt5.
Я хочу убрать стрелочку возле выбора месяца, однако не знаю как это сделать. Помогите пожалуйста.
Вот сам код:
Calendar_StyleSheet = '''
/* Верхняя область */
#qt_calendar_navigationbar {
background-color: rgb(0, 188, 212);
min-width: 800px;
max-width: 800px;
min-height: 35px;
max-height: 35px;
}
/* Кнопка последнего месяца и кнопка следующего месяца */
#qt_calendar_prevmonth, #qt_calendar_nextmonth {
border: none; /* убрать границу */
margin-top: 0px;
color: white;
min-width: 30px;
max-width: 30px;
min-height: 30px;
max-height: 30px;
border-radius: 10px; /* выглядит как эллипс */
font-weight: bold; /* шрифт полужирный */
qproperty-icon: none;
background-color: transparent; /* Цвет фона прозрачный */
}
#qt_calendar_prevmonth {
qproperty-text: "<"; /* Изменить текст кнопки */
}
#qt_calendar_nextmonth {
qproperty-text: ">";
}
#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed {
background-color: rgba(235, 235, 235, 100);
}
/* год, месяц */
#qt_calendar_yearbutton, #qt_calendar_monthbutton {
color: white;
margin: -1px;
min-width: -1px;
border-radius: 15px;
background-color: rgba(0, 188, 212, 100)
}
#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed {
background-color: rgba(235, 235, 235, 100);
}
/* Поле ввода года */
#qt_calendar_yearedit {
min-width: 85px;
color: white;
background: transparent; /* Сделать фон окна ввода прозрачным */
}
#qt_calendar_yearedit::up-button { /* Кнопка вверх */
width: 25px;
subcontrol-position: right;
}
#qt_calendar_yearedit::down-button { /* Кнопка вниз */
width: 25px;
subcontrol-position: left;
}
/* меню выбора месяца */
CalendarWidget_QToolButton_QMenu {
background-color: white;
}
CalendarWidget_QToolButton_QMenu_item {
padding: 10px;
}
CalendarWidget_QToolButton_QMenu_item_selected_enabled {
background-color: rgb(230, 230, 230);
selection-color: rgb(45, 86, 100);
selection-background-color: rgb(205, 217, 226);
}
CalendarWidget_QToolButton_menu-indicator {
subcontrol-position: right center;
}
/* ниже календарной формы */
#qt_calendar_calendarview {
outline: 0px; /* Удалить выделенную пунктирную рамку */
selection-background-color: rgb(0, 188, 212);
}
'''
Ответы (1 шт):
Автор решения: S. Nick
→ Ссылка
Зачем вы поломали все стили, которые начинаются с CalendarWidget ??
Исправьте все и добавьте строку
image: none; /* Удалите маленькую стрелку под выбором месяца !!! */
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextCharFormat, QBrush, QColor
from PyQt5.QtWidgets import QApplication, QCalendarWidget
class CalendarWidget(QCalendarWidget):
def __init__(self, *args, **kwargs):
super(CalendarWidget, self).__init__(*args, **kwargs)
# Вертикальный заголовок.
self.setVerticalHeaderFormat(self.NoVerticalHeader)
# Изменить цвета субботы и воскресенья
fmtGreen = QTextCharFormat()
fmtGreen.setForeground(QBrush(Qt.green))
self.setWeekdayTextFormat(Qt.Saturday, fmtGreen)
fmtOrange = QTextCharFormat()
fmtOrange.setForeground(QBrush(QColor(252, 140, 28)))
self.setWeekdayTextFormat(Qt.Sunday, fmtOrange)
Calendar_StyleSheet = '''
/* Верхняя область */
#qt_calendar_navigationbar {
background-color: rgb(0, 188, 212);
min-width: 800px;
max-width: 800px;
min-height: 35px;
max-height: 35px;
}
/* Кнопка последнего месяца и кнопка следующего месяца */
#qt_calendar_prevmonth, #qt_calendar_nextmonth {
border: none; /* убрать границу */
margin-top: 0px;
color: white;
min-width: 30px;
max-width: 30px;
min-height: 30px;
max-height: 30px;
border-radius: 10px; /* выглядит как эллипс */
font-weight: bold; /* шрифт полужирный */
qproperty-icon: none;
background-color: transparent; /* Цвет фона прозрачный */
}
#qt_calendar_prevmonth {
qproperty-text: "<"; /* Изменить текст кнопки */
}
#qt_calendar_nextmonth {
qproperty-text: ">";
}
#qt_calendar_prevmonth:hover, #qt_calendar_nextmonth:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_prevmonth:pressed, #qt_calendar_nextmonth:pressed {
background-color: rgba(235, 235, 235, 100);
}
/* год, месяц */
#qt_calendar_yearbutton, #qt_calendar_monthbutton {
color: white;
margin: -1px;
min-width: -1px;
border-radius: 15px;
background-color: rgba(0, 188, 212, 100)
}
#qt_calendar_yearbutton:hover, #qt_calendar_monthbutton:hover {
background-color: rgba(225, 225, 225, 100);
}
#qt_calendar_yearbutton:pressed, #qt_calendar_monthbutton:pressed {
background-color: rgba(235, 235, 235, 100);
}
/* Поле ввода года */
#qt_calendar_yearedit {
min-width: 85px;
color: white;
background: transparent; /* Сделать фон окна ввода прозрачным */
}
#qt_calendar_yearedit::up-button { /* Кнопка вверх */
width: 25px;
subcontrol-position: right;
}
#qt_calendar_yearedit::down-button { /* Кнопка вниз */
width: 25px;
subcontrol-position: left;
}
/* меню выбора месяца
? ? ????????????????????????????????
CalendarWidget_QToolButton_QMenu { зачем вы наставили подчеркивание ? */
CalendarWidget QToolButton QMenu {
background-color: white;
}
/* ? ? ??
CalendarWidget_QToolButton_QMenu_item { */
CalendarWidget QToolButton QMenu::item {
padding: 10px;
}
/* ? ? ?? ? ?
CalendarWidget_QToolButton_QMenu_item_selected_enabled { */
CalendarWidget QToolButton QMenu::item:selected:enabled {
background-color: rgb(230, 230, 230);
selection-color: rgb(45, 86, 100);
selection-background-color: rgb(205, 217, 226);
}
/* ? ??
CalendarWidget_QToolButton_menu-indicator { */
CalendarWidget QToolButton::menu-indicator {
image: none; /* Удалите маленькую стрелку под выбором месяца !!! */
subcontrol-position: right center;
}
/* ниже календарной формы */
#qt_calendar_calendarview {
outline: 0px; /* Удалить выделенную пунктирную рамку */
selection-background-color: rgb(0, 188, 212);
}
'''
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet(Calendar_StyleSheet)
w = CalendarWidget()
w.resize(800, 300)
w.show()
sys.exit(app.exec_())

