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.
mpVideoPlayer
->setGeometry
( QRect( 0,
0,
561,
351 ) );
mpVideoPlayer->setCursor( Qt::CrossCursor );
mpVideoPlayer = new QAxWidget( mpFrame );
mpVideoPlayer->setGeometry( QRect( 0, 0, 561, 351 ) );
mpVideoPlayer->setCursor( Qt::CrossCursor );
To copy to clipboard, switch view to plain text mode
void VideoViewerWindow
::mouseReleaseEvent( QMouseEvent *event
) {
if( event->button() == Qt::LeftButton )
{
QMessageBox::warning( this, tr
( "Position" ), tr
( "Left Button Pressed" ) );
}
else if( event->button() == Qt::RightButton )
{
QMessageBox::warning( this, tr
( "Position" ), tr
( "Right Button Pressed" ) );
}
}
void VideoViewerWindow::mouseReleaseEvent( QMouseEvent *event )
{
if( event->button() == Qt::LeftButton )
{
QString test = QString( event->x() ) + ", " + QString( event->y() );
QMessageBox::warning( this, tr( "Position" ), tr( "Left Button Pressed" ) );
}
else if( event->button() == Qt::RightButton )
{
QMessageBox::warning( this, tr( "Position" ), tr( "Right Button Pressed" ) );
}
}
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
Bookmarks