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

Meir Yanovich meiry242 at gmail.com
Sun May 23 14:37:13 CEST 2010


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/20100523/2e6e962b/attachment.html 


More information about the Qt-interest-old mailing list