to durbrak:
CTestWidget
::CTestWidget(QWidget* parent
){
setWindowFlags( Qt::FramelessWindowHint );
setFixedSize( 400, 400 );
mPixmap
= QPixmap( "C:\\ellipse.png" );
QBitmap mask
= mPixmap.
createHeuristicMask(true);
setMask( mask );
}
CTestWidget::~CTestWidget()
{
}
{
p.drawPixmap( 0, 0, mPixmap );
}
CTestWidget::CTestWidget(QWidget* parent )
:QWidget( parent )
{
setWindowFlags( Qt::FramelessWindowHint );
setFixedSize( 400, 400 );
mPixmap = QPixmap( "C:\\ellipse.png" );
QBitmap mask = mPixmap.createHeuristicMask(true);
setMask( mask );
}
CTestWidget::~CTestWidget()
{
}
void CTestWidget::paintEvent(QPaintEvent* e)
{
QPainter p( this );
p.drawPixmap( 0, 0, mPixmap );
}
To copy to clipboard, switch view to plain text mode
I knew I did it some time ago.
I attached a screen of how it looks.
The png is just a black ellipse on a white background.
The method is limited because it does not work when the image you want to display contains transparent shadings ( such as shadows ).
However, you can give the whole masked widget a shadow if you set the flags Qt::FramessWindowHint | Qt::Popup.
Although, never tested it on Mac.
regards
Bookmarks