Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QCalendarWidget does not update calendar when month changes on Mac OSX
kitchoi last edited by kitchoi
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.
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_()
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?
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(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_()
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.