Results 1 to 2 of 2

Thread: QCalendarWidget Navigation Bar PREV, NEXT month icons

  1. #1
    Join Date
    Apr 2021
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

    Screenshot 2021-04-28 110233.png

    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;}"
    )
    Last edited by ZennDogg; 28th April 2021 at 19:29.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,728
    Thanks
    13
    Thanked 1,608 Times in 1,535 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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:
    Qt Code:
    1. QCalendarWidget QToolButton#qt_calendar_nextmonth::right-arrow {icon: url(right_arrow.png);}
    2. QCalendarWidget QToolButton::right-arrow {icon: url(right_arrow.png);}
    3.  
    4. QCalendarWidget QToolButton#qt_calendar_nextmonth {icon: url(right_arrow.png);}
    To copy to clipboard, switch view to plain text mode 
    or equivakents using the "image" property.

Similar Threads

  1. Replies: 2
    Last Post: 8th April 2013, 06:40
  2. QCalendarWidget month-year selection
    By alitoh in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2012, 13:47
  3. Replies: 7
    Last Post: 19th May 2010, 13:24
  4. Replies: 4
    Last Post: 19th May 2009, 08:06
  5. QDateEdit Month/Day Rollover
    By giverson in forum Qt Programming
    Replies: 1
    Last Post: 7th January 2008, 18:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.