void Widget::on_pushButton_clicked(bool checked)
{
if(checked)
{
// //方法一
//#ifdef Q_OS_WIN32
// ::SetWindowPos( (HWND)this->winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE );
//#else
// this->setWindowFlags( this->windowFlags() | Qt::WindowStaysOnTopHint );
//#endif
//方法二
setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
show();//注意
}
else
{
//#ifdef Q_OS_WIN32
// ::SetWindowPos( (HWND)this->winId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE );
//#else
// this->setWindowFlags( this->windowFlags() & ~Qt::WindowStaysOnTopHint );
//#endif
//setWindowFlags(Qt::Widget);//ok
setWindowFlags( windowFlags() & ~Qt::WindowStaysOnTopHint );
show();//注意
}
}
窗体部件效果之窗体置顶
最新推荐文章于 2019-12-09 11:20:58 发布