1 Attachment(s)
QCalendarWidget Navigation Bar PREV, NEXT month icons
Hello. Using PyQt5 with Python 3.9. I wish to change the ugly green navigation arrows on the navigation bar. Been on the internet for several hours trying different solutions and can't get them to work. This is the last modification to the widget I want to make. Any help would be greatly appreciated.
Attachment 13633
Here is my stylesheet params:
self.cal.setStyleSheet(
"QCalendarWidget QAbstractItemView{background-color: black;color: rgba(162,201,229,255);selection-background-color: rgb(46, 46, 46);selection-color: lightgray;selection-border: 1px solid black;}"
"QCalendarWidget QWidget{alternate-background-color: rgb(46, 46, 46);color: gray;}"
"QCalendarWidget QToolButton{background-color: black;color: rgb(155,145,155);font-size: 14px;font: bold;width: 70px;border: none;}"
"QCalendarWidget QToolButton#qt_calendar_prevmonth{qproperty-icon: left_arrow.png;}"
"QCalendarWidget QToolButton#qt_calendar_nextmonth{qproperty-icon: right_arrow.png;}"
)
Re: QCalendarWidget Navigation Bar PREV, NEXT month icons
Flying blind here, no Qt environment to test with.
A quick scan of the Qt source: The qt_calendar_prevmonth and qt_calendar_nextmonth buttons are of class QPrevNextCalButton, which is a QToolButton. The painting code is only very slightly different to the underlying QToolBar, so it should be quite styleable. The icons used are QStyle::SP_ArrowRight and QStyle::SP_ArrowLeft. These seem to be set explicitly and may overwrite styled versions.
From the styling reference:
When the QToolButton displays arrows, the ::up-arrow, ::down-arrow, ::left-arrow and ::right-arrow subcontrols are used.
I think you also want the "image" (<Qt 5.15) or "icon" property (>= Qt 5.15) and probably the url() function.
I'd try something like one of these:or equivakents using the "image" property.