Hello, everybody here..
I have a critical problem.
I want to make the background of QIconView transparent.
I had tried some things below, but all of them doesn't work!!!
1. set background origin, this works for QLabel , etc, but not for QIconView
setBackgroundOrigin
(QWidget::ParentOrigin);
viewport
()->setBackgroundOrigin
(QWidget::ParentOrigin);
setBackgroundOrigin(QWidget::ParentOrigin);
viewport()->setBackgroundOrigin(QWidget::ParentOrigin);
To copy to clipboard, switch view to plain text mode
2. set backgroundMode, but get i background fill with black, not i want
viewport()->setBackgroundMode(Qt::NoBackground)
setBackgroundMode(Qt::NoBackground);
viewport()->setBackgroundMode(Qt::NoBackground)
setBackgroundMode(Qt::NoBackground);
To copy to clipboard, switch view to plain text mode
3. use setMask, causes some X errors ? I don't know what it is. it seems critical.
void MyIconView::updateMask()
{
bm.fill( color0 );
QRect cr
= contentsRect
();
paint.begin( &bm, this );
paint.setBrush( color1 );
paint.setPen( color1 );
drawContents(&paint, cr.x(), cr.y(), cr.width(), cr.heigth()); // this cause some X error (invalid match.....some thing like this ... QT debug many things )
paint.end();
setMask( bm );
}
void MyIconView::updateMask()
{
QBitmap bm( size() );
bm.fill( color0 );
QRect cr = contentsRect();
QPainter paint;
paint.begin( &bm, this );
paint.setBrush( color1 );
paint.setPen( color1 );
drawContents(&paint, cr.x(), cr.y(), cr.width(), cr.heigth()); // this cause some X error (invalid match.....some thing like this ... QT debug many things )
paint.end();
setMask( bm );
}
To copy to clipboard, switch view to plain text mode
I can not find out a way to go through this function.
Any idea?
Thanks ...
/WX
Bookmarks