Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QCalendarWidget does not update calendar when month changes on Mac OSX
Qt 6.11 is out! See what's new in the release blog

QCalendarWidget does not update calendar when month changes on Mac OSX

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpyside2
2 Posts 2 Posters 943 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kitchoi
    wrote on last edited by kitchoi
    #1

    When the user clicks the left or right arrow buttons to switch months, the calendar does not update its view. Weirdly, clicking individual date causes the clicked item to be updated.

    To reproduce:

    try:
        from PyQt5.QtWidgets import *
    except ImportError:
        from PySide2.QtWidgets import *
    app = QApplication([])
    control = QMainWindow(None)
    control.setVisible(True)
    calendar = QCalendarWidget(control)
    control.setCentralWidget(calendar)
    app.exec_()
    

    Jul-06-2020 11-25-42.gif
    Changing the month by selecting it from the dropdown does not suffer from this problem.
    This seems to affect Mac OSX only, as I have tested this with Windows and Linux and have not observed the same issue.
    I am not sure if this is an issue of the Python wrapper, or a bug for Qt?

    System information:
    OSX 10.15.5
    Python 3.8

    Other packages:
    pip 19.2.3
    PySide2 5.15.0
    setuptools 41.2.0
    shiboken2 5.15.0

    For reference, this looks/feels like the issue in https://forum.qt.io/topic/107558/push-buttons-and-pixmaps-not-updating-refreshing-properly-in-pyqt-only-on-macos/7

    With that, I was able to "workaround" by adding setEnabled(False) and setEnabled(True) somehow when the layout change event occurs:

    try:
        from PyQt5 import QtCore
        from PyQt5.QtWidgets import *
    except ImportError:
        from PySide2 import QtCore
        from PySide2.QtWidgets import *
    
    class MyFilter(QtCore.QObject):
        def eventFilter(self, object, event):
            if event.type() == QtCore.QEvent.LayoutRequest:
                object.setEnabled(False)
                object.setEnabled(True)
            return super().eventFilter(object, event)
    
    app = QApplication([])
    control = QMainWindow(None)
    control.setVisible(True)
    calendar = QCalendarWidget(control)
    
    filter_ = MyFilter()
    calendar.installEventFilter(filter_)
    
    control.setCentralWidget(calendar)
    app.exec_()
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      On macOS 10.13.6, I have the situation in the other direction. The selection does not follow at all when changing the month.

      I saw there were patches going in for the model used by this widget so I wonder if this behaviour will change.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved