I figured out how to get my overlay to work on my DirectShow video. I just made a QPixmap of size 5x5 and put this on a QLabel of size 5x5 which I draw on top of the QAxWidget displaying my video. This works great instead of trying to create a transparent pixmap/label but I get a lot of flicker when I click on the video to draw the point. In my GUI building function I set these variables up like this:

Qt Code:
  1. mpOverlay = new QPixmap( 5, 5 );
  2. mpOverlay->fill( Qt::red );
  3.  
  4. mpOverlayLabel = new QLabel( mpVideoPlayer );
  5. mpOverlayLabel->setGeometry( QRect( 0, 0, 5, 5 ) );
  6. mpOverlayLabel->hide( );
  7. mpOverlayLabel->setPixmap( *mpOverlay );
To copy to clipboard, switch view to plain text mode 

Then whenever I click on the screen I do this:

Qt Code:
  1. if( event->type() == QEvent::MouseButtonRelease )
  2. {
  3. AzElPoint point;
  4. QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
  5.  
  6. point.frameNumber = getCurrentFrame( );
  7. point.xPos = mouseEvent->x( );
  8. point.yPos = mouseEvent->y( );
  9.  
  10. if( mouseEvent->button() == Qt::LeftButton )
  11. {
  12. // If left button, place mark on overlay to indicate position
  13. // and store position in array at the current frame index
  14. for( int i = 0 ; i < azElPoints.size( ) ; i++ )
  15. {
  16. if( azElPoints[i].frameNumber == getCurrentFrame( ) )
  17. {
  18. azElPoints.removeAt( i );
  19. erasePoint = true;
  20. }
  21. }
  22. azElPoints.push_back( point );
  23. printf( "x=%d, y=%d\n", point.xPos, point.yPos );
  24. update( );
  25. return true;
  26. }
  27. }
To copy to clipboard, switch view to plain text mode 

And my paint event handler just calls repaintWindow( ) which looks like this:

Qt Code:
  1. void VideoViewerWindow::repaintWindow( )
  2. {
  3. long lWidth, lHeight;
  4. HRESULT hr = pWindowlessControl->GetNativeVideoSize( &lWidth, &lHeight, NULL, NULL );
  5. RECT rcSrc, rcDest;
  6. // Set the source rectangle.
  7. SetRect( &rcSrc, 0, 0, lWidth, lHeight );
  8.  
  9. // Get the window client area.
  10. GetClientRect( (HWND) mpVideoPlayer->winId( ), &rcDest );
  11. // Set the destination rectangle.
  12. SetRect(&rcDest, 1, 1, 558, 349);
  13.  
  14. // Set the video position.
  15. hr = pWindowlessControl->SetVideoPosition( &rcSrc, &rcDest );
  16.  
  17. PAINTSTRUCT ps;
  18. HDC hdc;
  19. RECT rcClient;
  20. GetClientRect( (HWND) mpVideoPlayer->winId( ), &rcClient );
  21. hdc = BeginPaint( (HWND) mpVideoPlayer->winId( ), &ps );
  22. if( pWindowlessControl != NULL )
  23. {
  24. // Find the region where the application can paint by subtracting
  25. // the video destination rectangle from the client area.
  26. // (Assume that g_rcDest was calculated previously.)
  27. HRGN rgnClient = CreateRectRgnIndirect( &rcClient );
  28. HRGN rgnVideo = CreateRectRgnIndirect( &rcDest );
  29. CombineRgn( rgnClient, rgnClient, rgnVideo, RGN_DIFF );
  30.  
  31. // Paint on window.
  32. HBRUSH hbr = GetSysColorBrush( COLOR_BTNFACE );
  33. FillRgn( hdc, rgnClient, hbr );
  34.  
  35. // Clean up.
  36. DeleteObject( hbr );
  37. DeleteObject( rgnClient );
  38. DeleteObject( rgnVideo );
  39.  
  40. // Request the VMR to paint the video and draw the point chosen by the user.
  41. int i;
  42. for( i = 0 ; i < azElPoints.size( ) ; i++ )
  43. {
  44. if( azElPoints[i].frameNumber == getCurrentFrame( ) )
  45. {
  46. mpOverlayLabel->move( azElPoints[i].xPos - 2, azElPoints[i].yPos - 2 );
  47. mpOverlayLabel->show( );
  48. break;
  49. }
  50. }
  51. if( i == azElPoints.size( ) )
  52. {
  53. mpOverlayLabel->hide( );
  54. }
  55. HRESULT hr = pWindowlessControl->RepaintVideo( (HWND) mpVideoPlayer->winId( ), hdc );
  56. }
  57. }
To copy to clipboard, switch view to plain text mode 

You can see what I am doing is just showing/hiding the QLabel and then redrawing the video (ie. the QAxWidget) which in turns redraws the QLabel since it is a child of the QAxWidget. But when I click the screen, I want the dot (QPixmap/QLabel) to appear without causing the entire screen to flicker. Sometimes the screen flickers and sometimes it does not. And when it does flicker, sometimes the flicker lasts almost a half of a second - which is very noticeable. So any ideas on how to improve my function(s) to prevent this from flickering would be great! Thanks!