Results 1 to 3 of 3

Thread: QCalendarWidget - how to stop wheel events processing?

  1. #1
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QCalendarWidget - how to stop wheel events processing?

    For most widgets I can disable mouse wheel events by installing events filter. It doesn't work for QCalendarWidget.
    It works for months/years scrolling (on the header), but when I scroll on top of actual calendar view (the table view), the scrolling is processed anyway.

    How to disable it?

    I tried to get into the QTableView that is rendering the calendar by using:
    Qt Code:
    1. QObject* view = calendar->findChild<QTableView*>("qt_calendar_calendarview");
    2. view->installEventFilter(this);
    To copy to clipboard, switch view to plain text mode 
    I know it's an ugly hack to workaround the "private d pointer" pattern, but it was my only hope, since QCalendarWidget doesn't allow to do anything with the calendar view widget inside of it (which I find inconvenient). The filter I'm installing is implemented like this:
    Qt Code:
    1. bool MultiEditorDateTime::eventFilter(QObject* obj, QEvent* event)
    2. {
    3. if (event->type() == QEvent::Wheel)
    4. return true;
    5.  
    6. return MultiEditorWidget::eventFilter(obj, event);
    7. }
    To copy to clipboard, switch view to plain text mode 
    I even stopped in debug to see if the filter gets any events and indeed it does, but not the Wheel events. I wonder - what object does receive the wheel events?

    This method works fine for other widgets, like QComboBox or QTextEdit. I have problem only with QCalendarWidget (so far). Any hints?

    I'm using Qt 5.0.1.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QCalendarWidget - how to stop wheel events processing?

    Install the event filter on the view's viewport.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    googie (3rd July 2013)

  4. #3
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QCalendarWidget - how to stop wheel events processing?

    It worked! Thanks!

    Do you know any other way to accomplish this without using findChild() with hard-coded object name?

Similar Threads

  1. combining wheel events
    By mcarter in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2010, 05:59
  2. howto Processing GUI events until a thread exits
    By doggrant in forum Qt Programming
    Replies: 0
    Last Post: 5th October 2009, 15:50
  3. Wheel and QTest
    By skrzypu in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2008, 20:05
  4. Replies: 4
    Last Post: 20th February 2007, 12:35
  5. Delays in processing events
    By Caius Aérobus in forum Qt Programming
    Replies: 6
    Last Post: 7th April 2006, 12:42

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.