Qt将窗体变为顶层窗体

//重载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();

 

posted @ 2016-09-18 14:02  sz_leez  阅读(4325)  评论(0编辑  收藏  举报