Results 1 to 3 of 3

Thread: Pass event (QWheelEvent) to a specific widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Pass event (QWheelEvent) to a specific widget

    I have created a custom QWidget (MyWidget) which has a custom QTableView (MyTableVIew). I would like MyTableView to respond to scrolling anywhere within MyWidget (e.g. in the space around the MyTableView).

    I think that when MyWidget receives a QWheelEvent I need to pass the event explicitely to MyTableView. I've tried using QApplication::sendEvent in the MyWidget::wheelEvent handler, but it's causing an infinite loop where the event keeps being passed back to MyWidget::wheelEvent.

    I've tried calling wheelEvent->ignore() before calling QApplication::sendEvent, but that made no difference.

    I've done some reading and it seems that I could override notify() or event() or install an eventFilter. What would be the bast and most correct way to do this? I'm probably going to want to put other special event handling in, so I should probably go for the most powerful and flexible option.

    Thanks
    Stefan

  2. #2
    Join Date
    May 2021
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Pass event (QWheelEvent) to a specific widget

    you have to accept the event after you send the event i.e call wheelEvent->accept() after calling QApplication::sendEvent.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Wink Re: Pass event (QWheelEvent) to a specific widget

    A reply to an eleven year old post... some kind of record?

Similar Threads

  1. Replies: 7
    Last Post: 14th January 2010, 08:47
  2. Context Menu for specific items in a Tree Widget
    By manekineko in forum Qt Programming
    Replies: 0
    Last Post: 16th November 2009, 01:46
  3. Replies: 1
    Last Post: 3rd November 2009, 22:26
  4. Pass mouseEvent to sibling widget?
    By nish in forum Qt Programming
    Replies: 5
    Last Post: 1st September 2009, 13:00
  5. pass mouse event information to another widget
    By Rooster in forum Qt Programming
    Replies: 5
    Last Post: 12th July 2008, 04:23

Tags for this Thread

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.