重写showEvent函数 void showEvent(QShowEvent *e) { this->setAttribute(Qt::WA_Mapped); QWidget::showEvent(e); }