qt QWidget窗体最小化(showMinimized)后点任务栏恢复后界面卡死

RT,找到2个解决方法如下:
我的qt4.8.6 采用1方法解决问题,2方法无效

方法1 重写changeEvent
//头文件申明
void changeEvent(QEvent *e);

//函数实现
void myWidgetWindow::changeEvent(QEvent *e)
{
    switch (e->type()) 
    {
    case QEvent::WindowStateChange:
        {
            this->update();
            this->repaint();
            e->ignore();
            break;
        }
    default:
        break;
    }
}
方法2 重写showEvent
//头文件申明
void showEvent(QShowEvent *e);

//函数实现
void myWidgetWindow::showEvent(QShowEvent *e)
{
    this->setAttribute(Qt::WA_Mapped);
    QWidget::showEvent(e);
}

猜你喜欢

转载自blog.csdn.net/qiangzi4646/article/details/79743604