Results 1 to 3 of 3

Thread: Mouse Events in a widget

  1. #1
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Mouse Events in a widget

    Can mouse events only be captured by a class? Or can any specific widget capture an event? For instance, I have a video player window that uses a QAxWidget. This video player window has a series of buttons and sliders. I only want to capture the mouse events that occur within the actual video window itself, not the buttons.
    Qt Code:
    1. mpVideoPlayer = new QAxWidget( mpFrame );
    2. mpVideoPlayer->setGeometry( QRect( 0, 0, 561, 351 ) );
    3. mpVideoPlayer->setCursor( Qt::CrossCursor );
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void VideoViewerWindow::mouseReleaseEvent( QMouseEvent *event )
    2. {
    3. if( event->button() == Qt::LeftButton )
    4. {
    5. QString test = QString( event->x() ) + ", " + QString( event->y() );
    6.  
    7. QMessageBox::warning( this, tr( "Position" ), tr( "Left Button Pressed" ) );
    8. }
    9. else if( event->button() == Qt::RightButton )
    10. {
    11. QMessageBox::warning( this, tr( "Position" ), tr( "Right Button Pressed" ) );
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    When running this code, all events are captured no matter where in the VideoViewerWindow class. However, when I try to put mpVideoPlayer->accept() I get compile errors. Do I have to make mpVideoPlayer a subclass of QAxWidget for this to work?

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Mouse Events in a widget

    So you want to catch mpVideoPlayer's events?
    Maybe you could try to install an event filter on it?
    J-P Nurmi

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

    Rayven (5th May 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Mouse Events in a widget

    Thats what I was looking for! Thanks mucho!

Similar Threads

  1. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  2. Determining when mouse over widget without events
    By Kimmo in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2007, 10:48
  3. Handling Mouse Events of a parent widget
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2007, 18:44
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25

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.