After looking through adding an overlay through some DirectShow commands, I discovered DirectShow's functionality to add the overlay was not sufficient enough to handle my needs. Right now, I am trying to just create an overlay to put on top of my buttons to get a handle on how to use transparent overlays. Here is essentially what I want it to do.
I intialize a couple things like this:
privateLayoutWidget
->setGeometry
( QRect( 182,
429,
248,
40 ) );
mpButtonLayout
= new QHBoxLayout( privateLayoutWidget
);
QSize videoButtonSize
( 30,
25 );
mpGoBeginningButton
= new QToolButton( privateLayoutWidget
);
mpGoBeginningButton->setMinimumSize(videoButtonSize );
QFont webDings_font
( "Webdings",
12 );
mpGoBeginningButton->setFont( webDings_font );
mpGoBeginningButton->setText( "9" );
mpGoBeginningButton->setToolTip( "Jump to beginning of video" );
mpButtonLayout->addWidget( mpGoBeginningButton );
...
mpTest->fill( Qt::transparent );
QWidget* privateLayoutWidget = new QWidget( this );
privateLayoutWidget->setGeometry( QRect( 182, 429, 248, 40 ) );
mpButtonLayout = new QHBoxLayout( privateLayoutWidget );
QSize videoButtonSize( 30, 25 );
mpGoBeginningButton = new QToolButton( privateLayoutWidget );
mpGoBeginningButton->setMinimumSize(videoButtonSize );
QFont webDings_font( "Webdings", 12 );
mpGoBeginningButton->setFont( webDings_font );
mpGoBeginningButton->setText( "9" );
mpGoBeginningButton->setToolTip( "Jump to beginning of video" );
mpButtonLayout->addWidget( mpGoBeginningButton );
...
mpTest = new QPixmap( 500, 500 );
mpTest->fill( Qt::transparent );
To copy to clipboard, switch view to plain text mode
Then to draw my pixmap onto my object, I do the following:
if( event
->type
( ) == QEvent::Paint ) {
if( pMediaSeeking != NULL )
{
painter2
->setPen
( QPen( Qt
::green,
3 ) );
for( int i = 0 ; i < azElPoints.size( ) ; i++ )
{
if( azElPoints[i].frameNumber == getCurrentFrame( ) )
{
if( erasePoint == true )
{
// Fill the overlay with transparent again since using a
// transparent pen does not remove the red dot.
mpTest->fill( Qt::transparent );
}
painter2->drawPoint( azElPoints[i].xPos, azElPoints[i].yPos );
}
}
//updateAlphaBitmap( );
repaintWindow( );
delete painter2;
painter->drawPixmap( 0, 0, *mpTest );
delete painter;
return true;
}
}
if( event->type( ) == QEvent::Paint )
{
if( pMediaSeeking != NULL )
{
QPainter* painter2;
painter2 = new QPainter( mpTest );
painter2->setPen( QPen( Qt::green, 3 ) );
for( int i = 0 ; i < azElPoints.size( ) ; i++ )
{
if( azElPoints[i].frameNumber == getCurrentFrame( ) )
{
if( erasePoint == true )
{
// Fill the overlay with transparent again since using a
// transparent pen does not remove the red dot.
mpTest->fill( Qt::transparent );
}
painter2->drawPoint( azElPoints[i].xPos, azElPoints[i].yPos );
}
}
//updateAlphaBitmap( );
repaintWindow( );
delete painter2;
QPainter *painter = new QPainter( mpGoBeginningButton );
painter->drawPixmap( 0, 0, *mpTest );
delete painter;
return true;
}
}
To copy to clipboard, switch view to plain text mode
Is this the correct way to try and make a transparent QPixmap because if so, I cannot get it to work. I am thinking maybe I should do something other than a fill( transparent ) to make the transparent QPixmap besides the occasional dot of color, but I do not know what it is that I am missing. Any more guidance with this would be great! Thanks!
Bookmarks