Results 1 to 2 of 2

Thread: QWheelEvent not working in event(QEvent*e) reimplementation

  1. #1
    Join Date
    Jul 2011
    Location
    Paris
    Posts
    31
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWheelEvent not working in event(QEvent*e) reimplementation

    Hello

    I am trying to catch the wheel event of my QGraphicsView subclass and for this I am reimplementing the event() method. When I do :

    Qt Code:
    1. bool GraphicsView::event(QEvent* event)
    2. {
    3.  
    4. if(event->type() == QEvent::Wheel){
    5. qDebug("ENTERED")
    6. return false;
    7. }
    8.  
    9. return QGraphicsView::event(event);
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

    This is just to test and I noticed that when I move the wheel the if statement never gets accessed. What is the proper way to say "if the event is a mouse wheel event" to be able to implement what I need inside the if statement??

    Thanks.


    Added after 24 minutes:


    Found the problem, since I already also had an implementation of the wheelEvent in my QGV class I just forgot to call the super class in my implementation.
    Adding QGraphicsView::wheelEvent() made the above work as expected
    Last edited by Sergex; 1st December 2011 at 18:18.

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

    Default Re: QWheelEvent not working in event(QEvent*e) reimplementation

    Why not just reimplement wheelEvent in the first place?

Similar Threads

  1. Pass event (QWheelEvent) to a specific widget
    By stefanadelbert in forum Qt Programming
    Replies: 2
    Last Post: 5th May 2021, 03:10
  2. QEvent::KeyPress problem, when will this event appear?
    By batileon in forum Qt Programming
    Replies: 11
    Last Post: 17th June 2011, 05:23
  3. [Qt4.5] event(QEvent * event) freeze application
    By czlowiekcien in forum Newbie
    Replies: 2
    Last Post: 25th May 2009, 20:25
  4. keyPressEvent() reimplementation
    By aurelius in forum Newbie
    Replies: 5
    Last Post: 30th October 2008, 16:23
  5. event(QEvent * event)
    By rajaraob in forum Qt Programming
    Replies: 9
    Last Post: 26th February 2007, 20:25

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.