//重载resizeEvent和moveEvent两个函数,以保证窗体大小和位置改变后能时刻记住其位置 QRect curGemRect = mpWindow->geometry(); //激活mpWindow窗体为桌面的顶层窗体 Qt::WindowStates winStatus = Qt::WindowNoState; if (mpWindow->windowState() & Qt::WindowMaximized) { winStatus = Qt::WindowMaximized; } mpWindow->setWindowState(Qt::WindowMinimized); mpWindow->setWindowState(Qt::WindowActive | winStatus); mpWindow->setGeometry(curGemRect); mpWindow->activateWindow(); mpWindow->raise();