QT实现遮罩效果
void CalendarControl::DisableWidget(QWidget*_ppWidget)
{
if(_ppWidget != NULL)
{
ppWidget = _ppWidget;
oldPalette = ppWidget->palette();
oldWindowOpacity = ppWidget->windowOpacity();
ppWidget->setPalette(Qt::black);
ppWidget->setWindowOpacity(0.2);//设置窗口透明度
//ppWidget->setWindowFlags(Qt::FramelessWindowHint | ppWidget->windowFlags());//去掉标题栏
}
}
void CalendarControl::EnableWidget()
{
if(ppWidget != NULL)
{
ppWidget->setPalette(oldPalette);
ppWidget->setWindowOpacity(oldWindowOpacity);//设置窗口透明
}
}
void CalendarControl::closeEvent(QCloseEvent *event)
{
EnableWidget();
}