qt widget設置Qt::FramelessWindowHint和Qt::WA_TranslucentBackground, 會出現一個bug: 在最小化后還原時界面停止刷新



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 依然存在此問題

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM