Results 1 to 4 of 4

Thread: Create a QWheelEvent and pass it to a widget's wheelEvent

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Create a QWheelEvent and pass it to a widget's wheelEvent

    It should work, but probably the event gets eaten somewhere else. How do you have defined the pointer dsatsGrid? Can you make a small executable project reproducing your problem.

    EDIT: Here I made a simple working pice of code:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Test : public QWidget
    4. {
    5. Q_OBJECT
    6. public:
    7. Test(QWidget *parent) : QWidget(parent)
    8. {}
    9.  
    10. protected:
    11. void wheelEvent(QWheelEvent *event)
    12. {
    13. qWarning() << Q_FUNC_INFO << event;
    14. }
    15. };
    16.  
    17.  
    18. class Base : public QPushButton
    19. {
    20. Q_OBJECT
    21.  
    22. public:
    23. Base(QWidget *parent) : QPushButton(parent)
    24. {
    25. setText("send weel event");
    26. test = new Test(this);
    27. connect(this, SIGNAL(clicked()),this, SLOT(send()));
    28. }
    29.  
    30. private Q_SLOTS:
    31. void send()
    32. {
    33. QWheelEvent event(QPoint(10, 10), 120, Qt::LeftButton, Qt::NoModifier);
    34. QApplication::sendEvent(test, &event);
    35. }
    36.  
    37. private:
    38. Test *test;
    39. };
    40.  
    41.  
    42.  
    43.  
    44. int main(int argc, char *argv[])
    45. {
    46. QApplication app(argc, argv);
    47.  
    48. Base b(0);
    49. b.show();
    50.  
    51. return app.exec();
    52. }
    53.  
    54. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 20th December 2010 at 14:08.

Similar Threads

  1. Pass event (QWheelEvent) to a specific widget
    By stefanadelbert in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2021, 03:10
  2. How to disable wheelEvent()
    By Markus in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2010, 18:42
  3. Pass mouseEvent to sibling widget?
    By nish in forum Qt Programming
    Replies: 5
    Last Post: 1st September 2009, 13:00
  4. Replies: 1
    Last Post: 26th July 2009, 15:08
  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
  •  
Qt is a trademark of The Qt Company.