Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make QCalendarWidget not scrollable?
Forum Updated to NodeBB v4.3 + New Features

How to make QCalendarWidget not scrollable?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 464 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.
  • H Offline
    H Offline
    Hai Anh Luu
    wrote on last edited by
    #1

    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.

    jsulmJ Pl45m4P 2 Replies Last reply
    0
    • H Hai Anh Luu

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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"?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      0
      • H Hai Anh Luu

        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.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @Hai-Anh-Luu

        Maybe you can catch the QWheelEvent in your CalendarWidget class and ignore it.
        You could use an eventFilter for that.

        • https://doc.qt.io/qt-6/qwheelevent.html#details

        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        H 1 Reply Last reply
        0
        • jsulmJ jsulm

          @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"?

          H Offline
          H Offline
          Hai Anh Luu
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          1
          • Pl45m4P Pl45m4

            @Hai-Anh-Luu

            Maybe you can catch the QWheelEvent in your CalendarWidget class and ignore it.
            You could use an eventFilter for that.

            • https://doc.qt.io/qt-6/qwheelevent.html#details
            H Offline
            H Offline
            Hai Anh Luu
            wrote on last edited by
            #5

            @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()
            
            JonBJ 1 Reply Last reply
            0
            • H Hai Anh Luu

              @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()
              
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @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 solutuon

              Install the event filter on the view's viewport.

              1 Reply Last reply
              1

              • Login

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