qt widget设置Qt::FramelessWindowHint和Qt::WA_TranslucentBackground, 会出现一个bug: 在最小化后还原时界面停止刷新

Widget with Qt::FramelessWindowHint and Qt::WA_TranslucentBackground stops painting after minimize/restore

被这个问题折腾了好几天, 真特么郁闷

该bug在qt 5.1.1中修复, bugreport链接 https://bugreports.qt-project.org/browse/QTBUG-17548
这个bug都发现N久了, 现在才修复

之前的版本的话, 可以试下下面的方法, 基本可用, 但在setwindowflag后, 任务栏图标会滑动一下, 某些电脑可能还会略微闪烁
void TestDlg::changeEvent( QEvent* e )
{

if( e->type() == QEvent::WindowStateChange)
{
if(this->windowState() & Qt::WindowMinimized )
{
//do something after minimize
}
else
{
setWindowFlags(Qt::Window);//set normal window flag
setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);//and return to your old flags

this->showNormal();

}
}
}
Qt 真是各种坑呐

 

补充: 该方法对qmainwindow无效, 在Qt5.1 qmainwindow 依然存在此问题

 

相关文章:

  • 2022-01-10
  • 2022-01-10
  • 2022-12-23
  • 2022-02-07
  • 2021-10-28
  • 2022-12-23
  • 2021-04-25
  • 2022-01-14
猜你喜欢
  • 2021-05-23
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2021-11-21
  • 2021-11-13
  • 2021-06-22
相关资源
相似解决方案