How to make QCalendarWidget not scrollable?
-
Recently I'm working with QCalendarWidget.
Currently, when the user scrolls the QCalendarWidget the months change, I don't want that to happen. How to turn it off? Someone help me, thank you very much. -
@Hai-Anh-Luu said in How to make QCalendarWidget not scrollable?:
when the user scrolls
What do you mean by that? What does the user "scroll"?
-
Maybe you can catch the
QWheelEvent
in your CalendarWidget class and ignore it.
You could use an eventFilter for that. -
@jsulm I'm sorry that my English is not good. I mean, I don't want to scroll the mouse to change the month in QCalendarWidget. Because now I have buttons to change the month and year, so when my mouse moves over the QCalendarWidget, I don't want to change the month when I try to scroll there
-
@Pl45m4 this is my code, but QCalendarWidget still change month when i scroll in QCalendarWidget area.
class CustomCalendar(QCalendarWidget): def __init__(self): super().__init__() def wheelEvent(self, event: PySide6.QtGui.QWheelEvent) -> None: event.ignore()
-
@Hai-Anh-Luu
I don't know about the specific "change month", but see https://www.qtcentre.org/threads/55248-QCalendarWidget-how-to-stop-wheel-events-processing from 2013(!) with apparent solutuonInstall the event filter on the view's viewport.