PDA

View Full Version : Darken Widgets Behind a Dialog



johnsoga
23rd August 2010, 21:35
My application is running on an embedded platform. There is a home screen that has a stacked widget that lets you switch between different modes. I display a dialog in the center of the screen for things like setup and alarms. Currently I try to darken the background by drawing a translucent widget over the home sceen and then the dialog over that. Here is the code for my overlay widget:



Overlay::Overlay( QWidget *parent_p )
: QWidget( parent_p )
{
setAutoFillBackground( true );

QPalette pal( palette() );
QColor color;
color.setRgba( FILL_COLOR );
pal.setBrush( QPalette::Window, QBrush( color ) );

setPalette( pal );

if ( parent_p )
{
resize( parent_p->size() );
}
}


This is really slow to draw and clear. Does anyone have a better solution for darkening the widgets behind a dialog?