[Qt-interest] setOpacity(0) doesn't fully work on masked QDialog

Meir Yanovich meiry242 at gmail.com
Mon May 24 05:24:53 CEST 2010


well i found the answer and its :
setAttribute(Qt::WA_TranslucentBackground, true);

On Sun, May 23, 2010 at 3:37 PM, Meir Yanovich <meiry242 at gmail.com> wrote:

> Hi all
> i try to set Opacity on masked QDialog but it doesn't fully set it
> i still have the Main QDialog background color shown , it is masked with
> round corners
> only the round corners get Opacity ..
> here is the code it is in the paintEvent method :
>
> QPainter painter(this);
>     painter.setRenderHints(QPainter::Antialiasing);
>     const QPalette& pal = palette();
>     float thickline = 1.5;//_sizes.thicker_line();
>     float border_rad = thickline * 4.0;
>     float w = width();
>     float h = height();
>     QImage mask_img(width(), height(), QImage::Format_Mono);
>     mask_img.fill(0xff);
>     QPainter mask_ptr(&mask_img);
>     mask_ptr.drawRoundedRect( QRectF( 0, 0, w, h),
>                                   border_rad+thickline/2.0,
>                                   border_rad+thickline/2.0 );
>
>    QBitmap bmp = QBitmap::fromImage(mask_img);
>         setMask( bmp );
>
>         QBrush bg_brush( pal.color(QPalette::Active, QPalette::Window) );
>         QPen border_pen( pal.color(QPalette::Active, QPalette::Dark) );
>         border_pen.setWidthF(thickline);
>         border_pen.setJoinStyle(Qt::RoundJoin);
>         painter.setPen(border_pen);
>         QRectF bg_rect = QRectF( thickline/2.0,
>                                 thickline/2.0,
>                                 w-thickline,
>                                 h-thickline );
>
>         painter.setBrush(bg_brush);
>
>         painter.setOpacity(0);   <-----------------------------------HERE
> IS THE PROBLEMATIC CODE
>         mask_ptr.setOpacity(0);
>
>         mask_ptr.drawRoundedRect( QRectF( 0, 0, w, h),
>                                   border_rad+thickline/2.0,
>                                   border_rad+thickline/2.0 );
>
>         painter.drawRoundedRect( bg_rect,
>                                  border_rad,
>                                  border_rad );
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100524/7f20ab68/attachment.html 


More information about the Qt-interest-old mailing list